using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Security;
using System.Threading;
using System.Transactions;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
using OracleInternal.BinXml;
using OracleInternal.Common;
using OracleInternal.ConnectionPool;
using OracleInternal.I18N;
using OracleInternal.Network;
using OracleInternal.TTC;
using OracleInternal.TTC.Accessors;

namespace OracleInternal.ServiceObjects
{
	internal class OracleConnectionImpl : PoolResource<OraclePoolManager, OraclePool, OracleConnectionImpl>
	{
		internal delegate void OracleConnectionCloseEventHandler();

		internal class ONSSubscriptionMetadata
		{
			internal string m_domainName;

			internal string m_serviceName;

			internal string m_databaseName;

			internal int m_conTimeout;

			internal string m_onsHASubscrPatter;

			internal string m_onsRLBSubscrPatter;

			internal string m_onsConfigFromDb;

			internal bool m_bRegisterForHA;

			internal bool m_bRegisterForRLB;

			internal bool m_bREgisterForChunkMove;
		}

		private object lockOnWeakReferenceObjList = new object();

		internal bool m_bCanUseSecureCQN;

		internal bool m_bClientInitiatedConnection;

		internal string m_listenerClientId;

		private List<WeakReference> listofWeakReferenceObj = new List<WeakReference>();

		private ObxmlProcessor m_obxmlProcessor = new ObxmlProcessor();

		internal CacheWithLRUList<ulong, ObxmlToken> m_ElementAttributeTokens;

		internal CacheWithLRUList<ulong, ObxmlToken> m_NamespaceTokens;

		private object m_readerImplLock = new object();

		internal bool m_preferredReaderImplTaken;

		private OracleDataReaderImpl m_preferredReaderImpl;

		private object m_commandImplLock = new object();

		internal bool m_preferredCommandImplTaken;

		private OracleCommandImpl m_preferredCommandImpl = new OracleCommandImpl
		{
			m_bPooled = true
		};

		internal const int Default_DotNetCharSet = 1000;

		internal const int Default_DotNetNCharSet = 1000;

		internal const int TDM_SYSDBA_ERROR = 12692;

		internal const string SERVER_POOLED = "POOLED";

		internal static char[] delim;

		internal static HashSet<string> dbsRegisteredForHA;

		internal static HashSet<string> servicesRegisteredForRLB;

		internal static HashSet<string> shardDBRegisteredForChunk;

		internal const long TTIEOCFRO = 1L;

		internal const long TTIEOCCUR = 2L;

		internal const long TTIEOCDON = 4L;

		internal const long TTIEOCECT = 8L;

		internal const long TTIEOCFSE = 16L;

		internal const long TTIEOCFPR = 32L;

		internal const long TTIEOCFSW = 64L;

		internal const long TTIEOCFMF = 128L;

		internal const long TTIEOCETS = 256L;

		internal const long TTIEOCFCP = 512L;

		internal const long TTIEOCFIV = 2147483648L;

		internal const byte END_TO_END_CID_INDEX = 0;

		internal const byte END_TO_END_MODULE_INDEX = 1;

		internal const byte END_TO_END_ACTION_INDEX = 2;

		internal const byte END_TO_END_CLINFO_INDEX = 3;

		internal const byte END_TO_END_STATE_INDEX_MAX = 4;

		internal bool m_bConnected;

		internal Hashtable StCfgHT;

		internal Hashtable ObCfgHT;

		internal Hashtable ObTnsHT;

		internal Hashtable ObLdpHT;

		internal string m_TNS_ADMIN;

		internal OracleCommunication m_oracleCommunication;

		internal MarshallingEngine m_marshallingEngine;

		protected Hashtable m_proxySessionProperties;

		internal Hashtable m_sessionProperties;

		internal AutoResetEvent m_connectionFreeToUseEvent = new AutoResetEvent(initialState: true);

		internal WaitHandle[] m_waitHandlesToStartExecution;

		internal object m_tuningLock = new object();

		private Dictionary<string, int> m_samples = new Dictionary<string, int>();

		private int m_samplesCount;

		internal static object m_lockForONSSubscriptions;

		internal bool m_autoCommit;

		internal bool m_bRequestBoundaryToBeSet;

		internal bool m_bSetRequestBoundaryPiggybackSent;

		internal bool m_bRequestBoundaryToBeReset;

		internal System.Data.IsolationLevel m_currentIsolationLvl = System.Data.IsolationLevel.ReadCommitted;

		private TTCProtocolNegotiation m_protoNeg;

		private TTCDataTypeNegotiation m_dtyNeg;

		private TTCVersion m_ttcVersion;

		private TTCFetch m_ttcFetch;

		private TTCAuthenticate m_ttcAuth;

		private TTCExecuteSql m_executeSql;

		private TTCSimpleOperations m_ttcSimplOp;

		private TTCOPing m_ttcOPing;

		private TTCNotification m_ttcNotification;

		private TTCClose m_ttcClose;

		private TTCCancel m_ttcCancel;

		private TTCSwitchSession m_ttcSwitchSession;

		private TTCEndToEndMetrics m_ttcEndToEndMetrics;

		private TTCTransactionSE m_ttcTransactionSE;

		private TTCTransactionEN m_ttcTransactionEN;

		private TTCSessionGet m_ttcSessionGet;

		private TTCSessionRelease m_ttcSessionRelease;

		private TTCSessionState m_ttcSessState;

		private TTCChunkInfo m_ttcChunkInfo;

		internal bool m_sendShardingInfoPiggyback;

		internal string m_shardingKey;

		internal string m_superShardingKey;

		internal string m_chunkName;

		internal long m_logonMode;

		internal short m_serverCharacterSet;

		internal short m_serverNCharSet;

		internal byte m_serverFlags;

		internal byte[] m_serverCompiletimeCapabilities;

		internal byte[] m_serverRuntimeCapabilities;

		internal bool m_b32kTypeSupported;

		internal long m_endOfCallStatus;

		internal bool m_bSupportSessionStateOps;

		internal string[] m_endToEndMetrics = new string[4];

		internal bool[] m_endToEndMetricsModified = new bool[4];

		internal object m_lockForLists = new object();

		private ArrayList m_tempLOBsToBeFreed = new ArrayList(10);

		private ArrayList m_cursorsToBeClosed = new ArrayList(10);

		private ArrayList m_cursorsToBeCancelled = new ArrayList(10);

		internal StatementCache m_statementCache;

		internal OracleGlobalizationImpl m_oracleGlobalizationImpl;

		internal Transaction m_lastEnlistedTransaction;

		internal string m_onsConfigFromDb = string.Empty;

		internal string m_onsHASubscrPatter = string.Empty;

		internal string m_onsRLBSubscPatter = string.Empty;

		internal long m_failoverType;

		internal int m_maxIdentifierLength = 30;

		internal string m_editionName;

		internal string m_drcpConnectionClass;

		internal string m_drcpTagName;

		internal bool m_bDRCPUseMultitag;

		internal string m_drcpSessionPurity = "2";

		internal string m_drcpPLSQLCallback;

		internal Hashtable m_temporaryLobReferences = new Hashtable();

		internal OracleTimeZoneInfo? m_dbTimeZoneInfo;

		internal int m_lastErrorNum;

		internal bool m_isNewConnection;

		internal bool CurrentlyInTransaction
		{
			get
			{
				if ((m_marshallingEngine.m_endOfCallStatus & 2) != 0L)
				{
					return true;
				}
				return false;
			}
		}

		internal TTCSessionState SessionStateObject
		{
			get
			{
				if (m_ttcSessState == null)
				{
					m_ttcSessState = new TTCSessionState(m_marshallingEngine);
				}
				return m_ttcSessState;
			}
		}

		internal TTCChunkInfo TTCChunkInfoObject
		{
			get
			{
				if (m_ttcChunkInfo == null)
				{
					m_ttcChunkInfo = new TTCChunkInfo(m_marshallingEngine);
				}
				return m_ttcChunkInfo;
			}
		}

		internal TTCAuthenticate AuthenticateObject
		{
			get
			{
				if (m_ttcAuth == null)
				{
					m_ttcAuth = new TTCAuthenticate(m_marshallingEngine, m_pm.m_appThreadLCID);
				}
				return m_ttcAuth;
			}
		}

		internal TTCExecuteSql ExecuteSqlObject
		{
			get
			{
				if (m_executeSql == null)
				{
					m_executeSql = new TTCExecuteSql(m_marshallingEngine);
				}
				return m_executeSql;
			}
		}

		internal TTCSimpleOperations SimpleOperationsObject
		{
			get
			{
				if (m_ttcSimplOp == null)
				{
					m_ttcSimplOp = new TTCSimpleOperations(m_marshallingEngine);
				}
				return m_ttcSimplOp;
			}
		}

		internal TTCClose TTCCloseObject
		{
			get
			{
				if (m_ttcClose == null)
				{
					m_ttcClose = new TTCClose(m_marshallingEngine);
				}
				return m_ttcClose;
			}
		}

		internal TTCCancel TTCCancelObject
		{
			get
			{
				if (m_ttcCancel == null)
				{
					m_ttcCancel = new TTCCancel(m_marshallingEngine);
				}
				return m_ttcCancel;
			}
		}

		internal TTCNotification TTCNotificationObject
		{
			get
			{
				if (m_ttcNotification == null)
				{
					m_ttcNotification = new TTCNotification(m_marshallingEngine);
				}
				return m_ttcNotification;
			}
		}

		internal TTCSwitchSession TTCSwitchSessionObject
		{
			get
			{
				if (m_ttcSwitchSession == null)
				{
					m_ttcSwitchSession = new TTCSwitchSession(m_marshallingEngine);
				}
				return m_ttcSwitchSession;
			}
		}

		internal TTCSessionGet TTCSessionGetObject
		{
			get
			{
				if (m_ttcSessionGet == null)
				{
					m_ttcSessionGet = new TTCSessionGet(m_marshallingEngine);
				}
				return m_ttcSessionGet;
			}
		}

		internal TTCSessionRelease TTCSessionReleaseObject
		{
			get
			{
				if (m_ttcSessionRelease == null)
				{
					m_ttcSessionRelease = new TTCSessionRelease(m_marshallingEngine);
				}
				return m_ttcSessionRelease;
			}
		}

		internal TTCOPing TTCOPingObject
		{
			get
			{
				if (m_ttcOPing == null)
				{
					m_ttcOPing = new TTCOPing(m_marshallingEngine);
				}
				return m_ttcOPing;
			}
		}

		internal TTCEndToEndMetrics TTCEndToEndMetricsObject
		{
			get
			{
				if (m_ttcEndToEndMetrics == null)
				{
					m_ttcEndToEndMetrics = new TTCEndToEndMetrics(m_marshallingEngine);
				}
				return m_ttcEndToEndMetrics;
			}
		}

		internal TTCFetch TTCFetchObject
		{
			get
			{
				if (m_ttcFetch == null)
				{
					m_ttcFetch = new TTCFetch(m_marshallingEngine);
				}
				return m_ttcFetch;
			}
		}

		internal TTCTransactionSE TTCTransactionSE
		{
			get
			{
				if (m_ttcTransactionSE == null)
				{
					m_ttcTransactionSE = new TTCTransactionSE(m_marshallingEngine);
				}
				return m_ttcTransactionSE;
			}
		}

		internal TTCTransactionEN TTCTransactionEN
		{
			get
			{
				if (m_ttcTransactionEN == null)
				{
					m_ttcTransactionEN = new TTCTransactionEN(m_marshallingEngine);
				}
				return m_ttcTransactionEN;
			}
		}

		internal bool IsServerUsingBigSCN => m_marshallingEngine.m_bServerUsingBigSCN;

		internal bool IsSupportPromotableTransaction
		{
			get
			{
				if (m_dbMajorVersion > 11 || (m_dbMajorVersion == 11 && m_dbMajorVersion > 1) || (m_dbMajorVersion == 11 && m_dbMinorVersion == 1 && m_dbPatchsetVersion >= 7))
				{
					return true;
				}
				return false;
			}
		}

		internal int DatabaseMajorVersion => m_dbMajorVersion;

		internal int DatabaseMinorVersion => m_dbMinorVersion;

		internal int DatabasePatchsetVersion => m_dbPatchsetVersion;

		internal bool IsTZDataSentAsLocalTime => m_dtyNeg.m_sendTZDataAsLocalTime;

		internal byte[] GetLogicalTransactionId => m_marshallingEngine.m_ltxId;

		internal bool IsNewConnection
		{
			get
			{
				return m_isNewConnection;
			}
			set
			{
				m_isNewConnection = value;
			}
		}

		internal bool DRCPConnection => m_marshallingEngine.m_bDRCPConnection;

		internal string DRCPConnectionClass
		{
			get
			{
				return m_drcpConnectionClass;
			}
			set
			{
				m_drcpConnectionClass = value;
			}
		}

		internal string DRCPtagName
		{
			get
			{
				return m_drcpTagName;
			}
			set
			{
				m_drcpTagName = value;
			}
		}

		internal bool CanSendRequestBoundary
		{
			get
			{
				bool result = false;
				if (m_bSupportSessionStateOps || GetLogicalTransactionId != null || (FailoverTypeVal & 8) == 8 || (FailoverTypeVal & 0x20) == 32)
				{
					result = true;
				}
				return result;
			}
		}

		internal int SessionId
		{
			get
			{
				try
				{
					int result = -1;
					if (m_sessionProperties != null)
					{
						int.TryParse((string)m_sessionProperties["AUTH_SESSION_ID"], out result);
					}
					return result;
				}
				catch (Exception ex)
				{
					OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.get_SessionId, ex);
					throw;
				}
			}
			set
			{
				if (m_sessionProperties != null)
				{
					m_sessionProperties["AUTH_SESSION_ID"] = value.ToString();
				}
			}
		}

		internal int SerialNumber
		{
			get
			{
				try
				{
					int result = -1;
					if (m_sessionProperties != null)
					{
						int.TryParse((string)m_sessionProperties["AUTH_SERIAL_NUM"], out result);
					}
					return result;
				}
				catch (Exception ex)
				{
					OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.get_SerialNumber, ex);
					throw;
				}
			}
			set
			{
				if (m_sessionProperties != null)
				{
					m_sessionProperties["AUTH_SERIAL_NUM"] = value.ToString();
				}
			}
		}

		internal int ProxySessionId
		{
			get
			{
				try
				{
					int result = -1;
					if (m_proxySessionProperties != null)
					{
						int.TryParse((string)m_proxySessionProperties["AUTH_SESSION_ID"], out result);
					}
					return result;
				}
				catch (Exception ex)
				{
					OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.get_ProxySessionId, ex);
					throw;
				}
			}
		}

		internal int ProxySerialNumber
		{
			get
			{
				try
				{
					int result = -1;
					if (m_proxySessionProperties != null)
					{
						int.TryParse((string)m_proxySessionProperties["AUTH_SERIAL_NUM"], out result);
					}
					return result;
				}
				catch (Exception ex)
				{
					OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.get_ProxySerialNumber, ex);
					throw;
				}
			}
		}

		internal SessionType SessionType => m_sessionType;

		internal override string EditionName
		{
			get
			{
				string text = null;
				if (m_isDb11gR1OrHigher)
				{
					if (m_sessionProperties != null)
					{
						if (m_sessionProperties.ContainsKey("AUTH_ORA_EDITION"))
						{
							text = (string)m_sessionProperties["AUTH_ORA_EDITION"];
						}
					}
					else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AUTH_ORA_EDITION"))
					{
						text = (string)m_proxySessionProperties["AUTH_ORA_EDITION"];
					}
					if (string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(m_editionName))
					{
						if (m_editionName[0] == '"')
						{
							int num = m_editionName.IndexOf('"', 1);
							text = m_editionName.Substring(1, num - 1);
						}
						else
						{
							text = m_editionName.ToUpper();
						}
					}
				}
				return text;
			}
		}

		internal override string PdbName
		{
			get
			{
				string result = null;
				if (m_isDb12cR1OrHigher)
				{
					if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AL8KW_CONTAINER_NAME"))
					{
						result = ((string)m_sessionProperties["AL8KW_CONTAINER_NAME"]).ToLowerInvariant();
					}
					else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AL8KW_CONTAINER_NAME"))
					{
						result = ((string)m_proxySessionProperties["AL8KW_CONTAINER_NAME"]).ToLowerInvariant();
					}
				}
				return result;
			}
		}

		internal int MaxIdentifierLength
		{
			get
			{
				string s = null;
				if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AL8KW_MAX_IDEN_LENGTH"))
				{
					s = (string)m_sessionProperties["AL8KW_MAX_IDEN_LENGTH"];
				}
				int result = 0;
				int.TryParse(s, out result);
				return result;
			}
		}

		internal int MaxOpenCursors
		{
			get
			{
				string s = null;
				if (m_sessionProperties != null)
				{
					if (m_sessionProperties.ContainsKey("AUTH_MAX_OPEN_CURSORS"))
					{
						s = (string)m_sessionProperties["AUTH_MAX_OPEN_CURSORS"];
					}
				}
				else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AUTH_MAX_OPEN_CURSORS"))
				{
					s = (string)m_proxySessionProperties["AUTH_MAX_OPEN_CURSORS"];
				}
				int result = -1;
				int.TryParse(s, out result);
				return result;
			}
		}

		internal string OnsConfigFromDB
		{
			get
			{
				string result = null;
				if (m_sessionProperties != null)
				{
					if (m_sessionProperties.ContainsKey("AUTH_ONS_CONFIG"))
					{
						result = (string)m_sessionProperties["AUTH_ONS_CONFIG"];
					}
				}
				else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AUTH_ONS_CONFIG"))
				{
					result = (string)m_proxySessionProperties["AUTH_ONS_CONFIG"];
				}
				return result;
			}
		}

		internal string OnsHASubscriberPattern
		{
			get
			{
				string result = null;
				if (m_sessionProperties != null)
				{
					if (m_sessionProperties.ContainsKey("AUTH_ONS_HA_SUBSCR_PATTERN"))
					{
						result = (string)m_sessionProperties["AUTH_ONS_HA_SUBSCR_PATTERN"];
					}
				}
				else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AUTH_ONS_HA_SUBSCR_PATTERN"))
				{
					result = (string)m_proxySessionProperties["AUTH_ONS_HA_SUBSCR_PATTERN"];
				}
				return result;
			}
		}

		internal string OnsRLBSubscriberPattern
		{
			get
			{
				string result = null;
				if (m_sessionProperties != null)
				{
					if (m_sessionProperties.ContainsKey("AUTH_ONS_RLB_SUBSCR_PATTERN"))
					{
						result = (string)m_sessionProperties["AUTH_ONS_RLB_SUBSCR_PATTERN"];
					}
				}
				else if (m_proxySessionProperties != null && m_proxySessionProperties.ContainsKey("AUTH_ONS_RLB_SUBSCR_PATTERN"))
				{
					result = (string)m_proxySessionProperties["AUTH_ONS_RLB_SUBSCR_PATTERN"];
				}
				return result;
			}
		}

		internal long FailoverTypeVal
		{
			get
			{
				long result = 0L;
				string s = string.Empty;
				if (m_sessionProperties != null)
				{
					if (m_sessionProperties.Contains("AUTH_FAILOVER_TYPE"))
					{
						s = m_sessionProperties["AUTH_FAILOVER_TYPE"]!.ToString();
					}
				}
				else if (m_proxySessionProperties != null && m_proxySessionProperties.Contains("AUTH_FAILOVER_TYPE"))
				{
					s = m_proxySessionProperties["AUTH_FAILOVER_TYPE"]!.ToString();
				}
				try
				{
					long.TryParse(s, out result);
					return result;
				}
				catch
				{
					return result;
				}
			}
		}

		internal string InstanceName
		{
			get
			{
				string text = null;
				if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AUTH_SC_INSTANCE_NAME"))
				{
					text = (string)m_sessionProperties["AUTH_SC_INSTANCE_NAME"];
				}
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
		}

		internal override string ServiceName
		{
			get
			{
				string result = null;
				if (m_sessionProperties != null)
				{
					result = ((!m_sessionProperties.ContainsKey("AUTH_SC_SERVICE_NAME")) ? string.Empty : ((string)m_sessionProperties["AUTH_SC_SERVICE_NAME"]).ToLowerInvariant());
				}
				else if (m_proxySessionProperties != null)
				{
					result = ((!m_proxySessionProperties.ContainsKey("AUTH_SC_SERVICE_NAME")) ? string.Empty : ((string)m_proxySessionProperties["AUTH_SC_SERVICE_NAME"]).ToLowerInvariant());
				}
				return result;
			}
		}

		internal string DatabaseDomainName
		{
			get
			{
				string text = string.Empty;
				if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AUTH_SC_DB_DOMAIN"))
				{
					text = (string)m_sessionProperties["AUTH_SC_DB_DOMAIN"];
				}
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
		}

		internal string DatabaseUniqueName
		{
			get
			{
				string text = string.Empty;
				if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AUTH_SC_DBUNIQUE_NAME"))
				{
					text = (string)m_sessionProperties["AUTH_SC_DBUNIQUE_NAME"];
				}
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
		}

		internal string HostName
		{
			get
			{
				string text = string.Empty;
				if (m_sessionProperties != null && m_sessionProperties.ContainsKey("AUTH_SC_SERVER_HOST"))
				{
					text = (string)m_sessionProperties["AUTH_SC_SERVER_HOST"];
				}
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
		}

		internal string DatabaseId
		{
			get
			{
				string result = string.Empty;
				if (m_sessionProperties.ContainsKey("AUTH_DB_ID\0"))
				{
					result = m_sessionProperties["AUTH_DB_ID\0"]!.ToString();
				}
				if (m_sessionProperties.ContainsKey("AUTH_DB_ID"))
				{
					result = m_sessionProperties["AUTH_DB_ID"]!.ToString();
				}
				return result;
			}
			set
			{
				if (m_sessionProperties.ContainsKey("AUTH_DB_ID\0"))
				{
					m_sessionProperties["AUTH_DB_ID\0"] = value;
				}
				if (m_sessionProperties.ContainsKey("AUTH_DB_ID"))
				{
					m_sessionProperties["AUTH_DB_ID"] = value;
				}
			}
		}

		internal string DatabaseMountId
		{
			get
			{
				string result = string.Empty;
				if (m_sessionProperties.ContainsKey("AUTH_DB_MOUNT_ID\0"))
				{
					result = m_sessionProperties["AUTH_DB_MOUNT_ID\0"]!.ToString();
				}
				if (m_sessionProperties.ContainsKey("AUTH_DB_MOUNT_ID"))
				{
					result = m_sessionProperties["AUTH_DB_MOUNT_ID"]!.ToString();
				}
				return result;
			}
			set
			{
				if (m_sessionProperties.ContainsKey("AUTH_DB_MOUNT_ID\0"))
				{
					m_sessionProperties["AUTH_DB_MOUNT_ID\0"] = value;
				}
				if (m_sessionProperties.ContainsKey("AUTH_DB_MOUNT_ID"))
				{
					m_sessionProperties["AUTH_DB_MOUNT_ID"] = value;
				}
			}
		}

		internal string GloballyUniqueDatabaseId
		{
			get
			{
				string result = string.Empty;
				if (m_sessionProperties.ContainsKey("AUTH_GLOBALLY_UNIQUE_DBID\0"))
				{
					result = m_sessionProperties["AUTH_GLOBALLY_UNIQUE_DBID\0"]!.ToString();
				}
				if (m_sessionProperties.ContainsKey("AUTH_GLOBALLY_UNIQUE_DBID"))
				{
					result = m_sessionProperties["AUTH_GLOBALLY_UNIQUE_DBID"]!.ToString();
				}
				return result;
			}
			set
			{
				if (m_sessionProperties.ContainsKey("AUTH_GLOBALLY_UNIQUE_DBID\0"))
				{
					m_sessionProperties["AUTH_GLOBALLY_UNIQUE_DBID\0"] = value;
				}
				if (m_sessionProperties.ContainsKey("AUTH_GLOBALLY_UNIQUE_DBID"))
				{
					m_sessionProperties["AUTH_GLOBALLY_UNIQUE_DBID"] = value;
				}
			}
		}

		internal string PDBUniqueId
		{
			get
			{
				string result = string.Empty;
				if (m_sessionProperties.ContainsKey("AUTH_PDB_UID\0"))
				{
					result = m_sessionProperties["AUTH_PDB_UID\0"]!.ToString();
				}
				if (m_sessionProperties.ContainsKey("AUTH_PDB_UID"))
				{
					result = m_sessionProperties["AUTH_PDB_UID"]!.ToString();
				}
				return result;
			}
			set
			{
				if (m_sessionProperties.ContainsKey("AUTH_PDB_UID\0"))
				{
					m_sessionProperties["AUTH_PDB_UID\0"] = value;
				}
				if (m_sessionProperties.ContainsKey("AUTH_PDB_UID"))
				{
					m_sessionProperties["AUTH_PDB_UID"] = value;
				}
			}
		}

		internal event OracleConnectionCloseEventHandler ConnectionCloseEvent;

		internal void RegisterForConnectionClose(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.RegisterForConnectionClose);
			}
			try
			{
				lock (lockOnWeakReferenceObjList)
				{
					listofWeakReferenceObj.Add(new WeakReference(obj));
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.RegisterForConnectionClose, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.RegisterForConnectionClose);
				}
			}
		}

		internal void DeregisterForConnectionClose(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DeregisterForConnectionClose);
			}
			try
			{
				lock (lockOnWeakReferenceObjList)
				{
					int num = 0;
					while (num < listofWeakReferenceObj.Count)
					{
						if (listofWeakReferenceObj[num].Target == null)
						{
							listofWeakReferenceObj.Remove(listofWeakReferenceObj[num]);
							continue;
						}
						if (listofWeakReferenceObj[num].Target == obj)
						{
							listofWeakReferenceObj.Remove(listofWeakReferenceObj[num]);
							break;
						}
						num++;
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DeregisterForConnectionClose, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DeregisterForConnectionClose);
				}
			}
		}

		internal void FireConnectionCloseEvent()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FireConnectionCloseEvent);
			}
			List<WeakReference> list = new List<WeakReference>();
			try
			{
				lock (lockOnWeakReferenceObjList)
				{
					for (int i = 0; i < listofWeakReferenceObj.Count; i++)
					{
						if (listofWeakReferenceObj[i].IsAlive)
						{
							list.Add(listofWeakReferenceObj[i]);
						}
					}
				}
				for (int j = 0; j < list.Count; j++)
				{
					if (list[j].Target is OracleBFile)
					{
						((OracleBFile)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleBlob)
					{
						((OracleBlob)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleClob)
					{
						((OracleClob)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleRefCursor)
					{
						((OracleRefCursor)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleXmlStream)
					{
						((OracleXmlStream)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleXmlType)
					{
						((OracleXmlType)list[j].Target)?.Close();
					}
					else if (list[j].Target is OracleDataReaderImpl)
					{
						((OracleDataReaderImpl)list[j].Target)?.Close();
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FireConnectionCloseEvent, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FireConnectionCloseEvent);
				}
			}
		}

		internal ObxmlDecodeStream GetDecodeStream(OracleConnection conn, OracleBlob csxBlob)
		{
			if (m_ElementAttributeTokens == null)
			{
				m_ElementAttributeTokens = new CacheWithLRUList<ulong, ObxmlToken>(ObxmlTokenManager.MaxTokenPoolEntries / 100);
			}
			if (m_NamespaceTokens == null)
			{
				m_NamespaceTokens = new CacheWithLRUList<ulong, ObxmlToken>(ObxmlTokenManager.MaxTokenPoolEntries / 100);
			}
			return m_obxmlProcessor.GetDecodeStream(conn, csxBlob);
		}

		internal void DisposeDecodeStream()
		{
			m_obxmlProcessor.DisposeDecodeStream();
		}

		internal void CloseDecodeStream(ObxmlDecodeContext decodeContext)
		{
			m_obxmlProcessor.CloseDecodeStream(decodeContext);
		}

		internal OracleDataReaderImpl GetInitializedDataReaderImpl(Accessor[] defineAccessors, SQLMetaData sqlMetaData, int cursorId, int noOfRowsFetched, CachedStatement cachedStmt, OracleIntervalDS sessionTimeZone, long initialLongFS, long clientInitialLOBFS, long internalInitialLOBFS, long internalInitialJSONFS, long[] snapshotSCN, bool metadataHasImplicitROWIDcolumn = false, bool bInitialLongFetchSizeModified = false)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl);
			}
			try
			{
				OracleDataReaderImpl oracleDataReaderImpl = null;
				if (m_preferredReaderImplTaken)
				{
					oracleDataReaderImpl = new OracleDataReaderImpl(this)
					{
						m_bPooled = false
					};
				}
				else
				{
					lock (m_readerImplLock)
					{
						if (m_preferredReaderImplTaken)
						{
							oracleDataReaderImpl = new OracleDataReaderImpl(this)
							{
								m_bPooled = false
							};
						}
						else
						{
							m_preferredReaderImplTaken = true;
							if (m_preferredReaderImpl == null)
							{
								m_preferredReaderImpl = new OracleDataReaderImpl(this)
								{
									m_bPooled = true
								};
							}
							oracleDataReaderImpl = m_preferredReaderImpl;
						}
					}
				}
				oracleDataReaderImpl.Init(defineAccessors, sqlMetaData, cursorId, noOfRowsFetched, cachedStmt, sessionTimeZone, initialLongFS, clientInitialLOBFS, internalInitialLOBFS, internalInitialJSONFS, snapshotSCN, metadataHasImplicitROWIDcolumn, bInitialLongFetchSizeModified);
				return oracleDataReaderImpl;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl);
				}
			}
		}

		internal OracleDataReaderImpl GetInitializedDataReaderImpl(List<OracleRefCursor> refCursors, long longFetchSize, long[] snapshotSCN)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl);
			}
			try
			{
				OracleDataReaderImpl oracleDataReaderImpl = null;
				if (m_preferredReaderImplTaken)
				{
					oracleDataReaderImpl = new OracleDataReaderImpl(this)
					{
						m_bPooled = false
					};
				}
				else
				{
					lock (m_readerImplLock)
					{
						if (m_preferredReaderImplTaken)
						{
							oracleDataReaderImpl = new OracleDataReaderImpl(this)
							{
								m_bPooled = false
							};
						}
						else
						{
							m_preferredReaderImplTaken = true;
							if (m_preferredReaderImpl == null)
							{
								m_preferredReaderImpl = new OracleDataReaderImpl(this)
								{
									m_bPooled = true
								};
							}
							oracleDataReaderImpl = m_preferredReaderImpl;
						}
					}
				}
				oracleDataReaderImpl.Init(refCursors, longFetchSize, snapshotSCN);
				return oracleDataReaderImpl;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetInitializedDataReaderImpl);
				}
			}
		}

		internal OracleCommandImpl getCommandImpl()
		{
			OracleCommandImpl oracleCommandImpl = null;
			if (m_preferredCommandImplTaken)
			{
				oracleCommandImpl = new OracleCommandImpl
				{
					m_bPooled = false
				};
			}
			else
			{
				lock (m_commandImplLock)
				{
					if (m_preferredCommandImplTaken)
					{
						oracleCommandImpl = new OracleCommandImpl
						{
							m_bPooled = false
						};
					}
					else
					{
						m_preferredCommandImplTaken = true;
						oracleCommandImpl = m_preferredCommandImpl;
					}
				}
			}
			oracleCommandImpl.Init();
			return oracleCommandImpl;
		}

		static OracleConnectionImpl()
		{
			delim = new char[3]
			{
				' ',
				'\t',
				'"'
			};
			dbsRegisteredForHA = new HashSet<string>();
			servicesRegisteredForRLB = new HashSet<string>();
			shardDBRegisteredForChunk = new HashSet<string>();
			m_lockForONSSubscriptions = new object();
		}

		public OracleConnectionImpl()
		{
			m_endToEndMetrics[2] = null;
			m_endToEndMetrics[0] = null;
			m_endToEndMetrics[1] = null;
			m_endToEndMetrics[3] = null;
			m_endToEndMetricsModified[2] = false;
			m_endToEndMetricsModified[0] = false;
			m_endToEndMetricsModified[1] = false;
			m_endToEndMetricsModified[3] = false;
			m_isNewConnection = true;
		}

		internal void SwitchIsolationLevel(System.Data.IsolationLevel isolationLevel)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SwitchIsolationLevel);
			}
			try
			{
				string text = null;
				text = ((System.Data.IsolationLevel.ReadCommitted != isolationLevel) ? "ALTER SESSION SET ISOLATION_LEVEL=SERIALIZABLE" : "ALTER SESSION SET ISOLATION_LEVEL=READ COMMITTED");
				ExecuteBasicSQL(text);
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)6144, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SwitchIsolationLevel, "OracleConnectionImpl.SwitchIsolationLevel(Session ID = ) " + SessionId + " Requested IsolationLevel " + isolationLevel.ToString() + " Current IsolationLevel " + m_currentIsolationLvl);
				}
				m_currentIsolationLvl = isolationLevel;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SwitchIsolationLevel, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SwitchIsolationLevel);
				}
			}
		}

		internal int WaitForConnectionForExecution(AutoResetEvent cmdCancelEvent = null)
		{
			int num = 0;
			if (cmdCancelEvent == null)
			{
				m_connectionFreeToUseEvent.WaitOne();
				num = 1;
			}
			else
			{
				if (m_waitHandlesToStartExecution == null || m_waitHandlesToStartExecution.Length < 2)
				{
					m_waitHandlesToStartExecution = new WaitHandle[2];
				}
				m_waitHandlesToStartExecution[0] = cmdCancelEvent;
				m_waitHandlesToStartExecution[1] = m_connectionFreeToUseEvent;
				num = WaitHandle.WaitAny(m_waitHandlesToStartExecution);
				if (num == 0)
				{
					throw new OracleException(1013, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1013));
				}
			}
			return num;
		}

		internal override bool PingServer()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PingServer);
			}
			try
			{
				bool result = true;
				TTCOPing tTCOPingObject = TTCOPingObject;
				try
				{
					m_connectionFreeToUseEvent.WaitOne();
					AddAllPiggyBackRequests();
					tTCOPingObject.Write();
					tTCOPingObject.m_marshallingEngine.m_oraBufWriter.FlushData();
					tTCOPingObject.ReadResponse();
					if (m_marshallingEngine.TTCErrorObject.ErrorCode != 0)
					{
						result = false;
					}
				}
				finally
				{
					m_connectionFreeToUseEvent.Set();
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PingServer, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PingServer);
				}
			}
		}

		internal void ExecuteBasicSQL(string sqlText)
		{
			int num = -1;
			int cursorId = 0;
			try
			{
				bool? bIsDefineInSelect = false;
				SqlStatementType sqlStatementType = OracleCommandImpl.GetSqlStatementType(sqlText, ref bIsDefineInSelect);
				num = WaitForConnectionForExecution();
				AddAllPiggyBackRequests();
				TTCExecuteSql executeSqlObject = ExecuteSqlObject;
				TTCExecuteSql.MarshalBindParameterValueHelper marshalBindParamsHelper = TTCExecuteSql.MarshalBindParameterValueHelper.Null;
				byte[] sqlStmtByteStream = m_marshallingEngine.m_dbCharSetConv.ConvertStringToBytes(sqlText, 0, sqlText.Length);
				executeSqlObject.SendExecuteRequest(this, sqlStmtByteStream, bHasReturningClause: false, 0, null, 0L, null, 0L, parse: true, execute: true, fetch: false, define: false, m_autoCommit, bDisableCompressedFetch: false, sqlStatementType, 0, 0, null, ref marshalBindParamsHelper, 0);
				Accessor[] defineAccessors = null;
				SQLMetaData sqlMetaData = null;
				int noOfRowsFetched = 0;
				long queryId = 0L;
				DataUnmarshaller dataUnmarshaller = null;
				long[] rowsAffectedByArrayBind = null;
				bool bMoreThanOneRowAffectedByDmlWithRetClause = false;
				List<TTCResultSet> implicitRSList = null;
				OracleException exceptionForArrayBindDML = null;
				bool bThrowArrayBindRelatedErrors = true;
				bool hasMoreRowsInDB = false;
				executeSqlObject.ReceiveExecuteResponse(ref defineAccessors, null, bHasReturningParams: false, ref sqlMetaData, SqlStatementType.OTHERS, -1L, 0, out noOfRowsFetched, ref queryId, 0, 0L, 0L, 0L, null, bAllInputBinds: false, 0, ref dataUnmarshaller, ref marshalBindParamsHelper, out rowsAffectedByArrayBind, bDefineDone: false, ref bMoreThanOneRowAffectedByDmlWithRetClause, ref implicitRSList);
				VerifyExecution(out cursorId, bThrowArrayBindRelatedErrors, sqlStatementType, 0, ref exceptionForArrayBindDML, out hasMoreRowsInDB);
				if (executeSqlObject.m_bSessionTimeZoneUpdated)
				{
					m_sessionTimeZone = new OracleIntervalDS(executeSqlObject.m_sessionTimeZone);
					executeSqlObject.m_bSessionTimeZoneUpdated = false;
				}
				m_sessionTimeZone = m_sessionTimeZone;
			}
			finally
			{
				if (num > 0)
				{
					m_connectionFreeToUseEvent.Set();
				}
				if (cursorId > 0)
				{
					AddCursorIdToBeClosed(cursorId);
				}
			}
		}

		internal int VerifyExecution(out int cursorId, bool bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, int arrayBindCount, ref OracleException exceptionForArrayBindDML, out bool hasMoreRowsInDB, bool bFirstIterationDone = false)
		{
			int result = 0;
			hasMoreRowsInDB = true;
			TTCError tTCErrorObject = m_marshallingEngine.TTCErrorObject;
			cursorId = tTCErrorObject.CursorId;
			if (tTCErrorObject.ErrorCode != 0)
			{
				if (tTCErrorObject.ErrorCode == 1403 && sqlStatementType == SqlStatementType.SELECT)
				{
					result = (int)tTCErrorObject.m_curRowNumber;
					tTCErrorObject.Initialize();
					hasMoreRowsInDB = false;
				}
				else
				{
					OracleException ex = null;
					char[] t = tTCErrorObject.m_marshallingEngine.m_charArrayPooler.Dequeue();
					if (tTCErrorObject.ErrorCode == 24381 && exceptionForArrayBindDML != null)
					{
						ex = exceptionForArrayBindDML;
					}
					else
					{
						ex = new OracleException(tTCErrorObject.ErrorCode, string.Empty, string.Empty, tTCErrorObject.m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(tTCErrorObject.ErrorMessage, 0, tTCErrorObject.ErrorMessage.Length, t), tTCErrorObject.m_errorPosition);
						if (tTCErrorObject.ErrorCode != 24381)
						{
							bThrowArrayBindRelatedErrors = true;
						}
					}
					if (arrayBindCount > 1 && tTCErrorObject.m_bindErrors != null)
					{
						TTCArrayBindError[] bindErrors = tTCErrorObject.m_bindErrors;
						for (int i = 0; i < bindErrors.Length; i++)
						{
							TTCArrayBindError tTCArrayBindError = bindErrors[i];
							ex.AddBindErrorToCollection(tTCArrayBindError.m_errorCode, string.Empty, string.Empty, tTCErrorObject.m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(tTCArrayBindError.m_errorMsg, 0, tTCArrayBindError.m_errorMsg.Length, t), bFirstIterationDone ? (tTCArrayBindError.m_rowOffset + 1) : tTCArrayBindError.m_rowOffset);
						}
					}
					if (t != null)
					{
						tTCErrorObject.m_marshallingEngine.m_charArrayPooler.Enqueue(ref t);
					}
					if (ex.Message.Contains("ORA-01000"))
					{
						OnOra01000Exception();
					}
					if ((tTCErrorObject.ErrorCode == 45582 || tTCErrorObject.ErrorCode == 45583) && m_instanceName != null && m_chunkName != null && m_pm != null)
					{
						m_pm.OnShardingError(tTCErrorObject.ErrorCode, m_instanceName, m_chunkName);
					}
					if (arrayBindCount == 0 || bThrowArrayBindRelatedErrors)
					{
						if (cursorId > 0)
						{
							AddCursorIdToBeClosed(cursorId);
						}
						if (tTCErrorObject.m_bindErrors == null || tTCErrorObject.m_bindErrors.Length == arrayBindCount)
						{
							throw ex;
						}
					}
					exceptionForArrayBindDML = ex;
				}
			}
			else
			{
				result = (int)tTCErrorObject.m_curRowNumber;
			}
			return result;
		}

		internal void OnOra01000Exception()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OnOra01000Exception);
			}
			try
			{
				if (m_pm == null || !m_pm.m_bSelfTuning || ProviderConfig.MaxStatementCacheSize.IsUserDefined)
				{
					return;
				}
				int maxCacheSize = m_statementCache.m_maxCacheSize;
				int num = 10;
				int num2 = maxCacheSize - num;
				if (num2 <= 0)
				{
					return;
				}
				m_pm.MaxAllowedValue = num2;
				if (m_pm.m_recommendedSCS > num2 && num2 >= 0)
				{
					m_pm.m_recommendedSCS = ((num2 <= ProviderConfig.MaxStatementCacheSize.Value) ? num2 : ProviderConfig.MaxStatementCacheSize.Value);
					if (m_pm.m_recommendedSCS > m_pm.MaxAllowedValue)
					{
						m_pm.m_recommendedSCS = m_pm.MaxAllowedValue;
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OnOra01000Exception, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OnOra01000Exception);
				}
			}
		}

		internal Hashtable HandleObBasedConfig(OracleConnection OC)
		{
			return HandleObBasedConfig(OC.TnsAdminInternal);
		}

		internal Hashtable HandleObBasedConfig(string tnsAdmin)
		{
			Hashtable configParamFrSqlnetora = ConfigBaseClass.m_configParamFrSqlnetora;
			m_TNS_ADMIN = tnsAdmin;
			string filePath = ProviderConfig.getFilePath(OraFiles.SqlNet, m_TNS_ADMIN, "sqlnet.ora");
			if (filePath.Length > 0)
			{
				StCfgHT = (Hashtable)ConfigBaseClass.m_configParameters.Clone();
				ObCfgHT = (Hashtable)ConfigBaseClass.m_configParameters.Clone();
				foreach (DictionaryEntry item in StCfgHT)
				{
					if (configParamFrSqlnetora[item.Key] != null && (bool)configParamFrSqlnetora[item.Key])
					{
						ObCfgHT.Remove(item.Key);
					}
				}
				ProviderConfig.NewOraFileParams(OraFiles.SqlNet, filePath, ObCfgHT, ObCfg: true);
			}
			filePath = ProviderConfig.getFilePath(OraFiles.TnsNames, m_TNS_ADMIN, "tnsnames.ora");
			if (filePath.Length > 0)
			{
				ObTnsHT = (Hashtable)ProviderConfig.ConfigDataSourcesMap.Clone();
				ProviderConfig.NewOraFileParams(OraFiles.TnsNames, filePath, ObTnsHT);
			}
			filePath = ProviderConfig.getFilePath(OraFiles.Ldap, m_TNS_ADMIN, "ldap.ora");
			if (filePath.Length > 0)
			{
				Hashtable lDAPCfParamFrAppConfig = ConfigBaseClass.m_LDAPCfParamFrAppConfig;
				Hashtable oracleConfigParameters = ConfigBaseClass.m_oracleConfigParameters;
				ObLdpHT = (Hashtable)ConfigBaseClass.m_LDAPconfigParameters.Clone();
				foreach (DictionaryEntry item2 in (Hashtable)ConfigBaseClass.m_LDAPconfigParameters.Clone())
				{
					if ((lDAPCfParamFrAppConfig[item2.Key] == null || !(bool)lDAPCfParamFrAppConfig[item2.Key]) && !oracleConfigParameters.ContainsKey(item2.Key))
					{
						ObLdpHT.Remove(item2.Key);
					}
				}
				ProviderConfig.NewOraFileParams(OraFiles.Ldap, filePath, ObLdpHT);
			}
			return null;
		}

		public override void Connect(ConnectionString cs, bool bOpenEndUserSession, OracleConnection connRefForCriteria, string instanceName = null)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, Trace.GetCPInfo(this, null, instanceName, "open"));
			}
			SecureString securePassword = null;
			SecureString secureProxyPassword = null;
			string userId = null;
			string proxyUserId = null;
			bool flag = false;
			bool flag2 = false;
			m_logonMode = 0L;
			try
			{
				if (connRefForCriteria != null)
				{
					if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaEdition) && string.IsNullOrEmpty(connRefForCriteria.m_criteriaPdbName))
					{
						m_editionName = connRefForCriteria.m_criteriaEdition;
					}
					if (!string.IsNullOrEmpty(connRefForCriteria.TnsAdminInternal))
					{
						HandleObBasedConfig(connRefForCriteria);
					}
				}
				else if (!string.IsNullOrEmpty(m_pm.m_tnsAdmin))
				{
					HandleObBasedConfig(m_pm.m_tnsAdmin);
				}
				SqlNetOraConfig sqlNetOraConfig = new SqlNetOraConfig((ObCfgHT != null) ? ObCfgHT : ConfigBaseClass.m_configParameters);
				if (m_bConnected)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.CON_ALREADY_OPEN));
				}
				m_cs = cs;
				if (m_cs.m_orclCredential != null)
				{
					if (m_cs.m_orclCredential.m_userId != "/")
					{
						userId = m_cs.m_orclCredential.m_userId;
					}
					if (m_cs.m_orclCredential.m_proxyUserId != "/")
					{
						proxyUserId = m_cs.m_orclCredential.m_proxyUserId;
					}
				}
				else
				{
					if (m_cs.m_userId != "/")
					{
						userId = m_cs.m_userId;
					}
					if (m_cs.m_proxyUserId != "/")
					{
						proxyUserId = m_cs.m_proxyUserId;
					}
				}
				if (m_pm.m_cs.m_pooling)
				{
					flag = m_pm.m_bDoNAHandShake;
					flag2 = m_pm.m_bDoExternalAuth;
					m_logonMode = m_pm.m_logonMode;
					if (m_pm.m_bUsingSEPSCredentials)
					{
						if (m_cs.m_orclCredential != null)
						{
							if (m_cs.m_orclCredential.m_userId == "/")
							{
								userId = m_pm.m_cs.m_sepsUserId;
								securePassword = m_pm.m_cs.m_sepsSecuredPassword;
								secureProxyPassword = m_pm.m_cs.m_orclCredential.m_secureProxyPassword;
							}
							else if (m_cs.m_orclCredential.m_proxyUserId == "/")
							{
								proxyUserId = m_pm.m_cs.m_sepsProxyUserId;
								secureProxyPassword = m_pm.m_cs.m_sepsSecuredProxyPassword;
								securePassword = m_pm.m_cs.m_orclCredential.m_securePassword;
							}
						}
						else if ("/" == m_cs.m_userId)
						{
							userId = m_pm.m_cs.m_sepsUserId;
							securePassword = m_pm.m_cs.m_sepsSecuredPassword;
							secureProxyPassword = m_pm.m_cs.m_securedProxyPassword;
						}
						else if ("/" == m_cs.m_proxyUserId)
						{
							proxyUserId = m_pm.m_cs.m_sepsProxyUserId;
							secureProxyPassword = m_pm.m_cs.m_sepsSecuredProxyPassword;
							securePassword = m_pm.m_cs.m_securedPassword;
						}
					}
					else if (cs.m_orclCredential != null)
					{
						securePassword = cs.m_orclCredential.m_securePassword;
						secureProxyPassword = cs.m_orclCredential.m_secureProxyPassword;
					}
					else
					{
						securePassword = cs.m_securedPassword;
						secureProxyPassword = cs.m_securedProxyPassword;
					}
				}
				else
				{
					if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSDBA)
					{
						m_logonMode |= 32L;
						flag2 = (flag = true);
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSOPER)
					{
						m_logonMode |= 64L;
						flag2 = (flag = true);
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSASM)
					{
						m_logonMode |= 4194304L;
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSBACKUP)
					{
						m_logonMode |= 16777216L;
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSDG)
					{
						m_logonMode |= 33554432L;
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSKM)
					{
						m_logonMode |= 67108864L;
					}
					else if (m_cs.m_dbaPrivilege == OracleDBAPrivilege.SYSRAC)
					{
						m_logonMode |= 134217728L;
					}
					if (!flag2 && ((m_cs.m_orclCredential != null && m_cs.m_orclCredential.m_userId == "/") || (m_cs.m_orclCredential != null && m_cs.m_orclCredential.m_proxyUserId == "/") || "/" == m_cs.m_userId || "/" == m_cs.m_proxyUserId))
					{
						if (!sqlNetOraConfig.WalletOverride)
						{
							flag2 = (flag = true);
							if (cs.m_orclCredential != null)
							{
								securePassword = cs.m_orclCredential.m_securePassword;
								secureProxyPassword = cs.m_orclCredential.m_secureProxyPassword;
							}
							else
							{
								securePassword = cs.m_securedPassword;
								secureProxyPassword = cs.m_securedProxyPassword;
							}
						}
						else
						{
							flag2 = false;
							string seps_userId = null;
							SecureString seps_secure_password = null;
							string walletPath = null;
							string walletFile = null;
							OraclePoolManager.FetchSEPSCredentails(m_cs.m_dataSource, out seps_userId, out seps_secure_password, out walletPath, out walletFile);
							if (m_cs.m_orclCredential != null)
							{
								if ("/" == m_cs.m_orclCredential.m_userId)
								{
									userId = seps_userId;
									securePassword = seps_secure_password;
									secureProxyPassword = m_cs.m_orclCredential.m_secureProxyPassword;
								}
								if ("/" == m_cs.m_orclCredential.m_proxyUserId)
								{
									proxyUserId = seps_userId;
									secureProxyPassword = seps_secure_password;
									securePassword = m_cs.m_orclCredential.m_securePassword;
								}
							}
							else
							{
								if ("/" == m_cs.m_userId)
								{
									userId = seps_userId;
									securePassword = seps_secure_password;
									secureProxyPassword = m_cs.m_securedProxyPassword;
								}
								if ("/" == m_cs.m_proxyUserId)
								{
									proxyUserId = seps_userId;
									secureProxyPassword = seps_secure_password;
									securePassword = m_cs.m_securedPassword;
								}
							}
						}
					}
					else if (m_cs.m_orclCredential != null)
					{
						securePassword = cs.m_orclCredential.m_securePassword;
						secureProxyPassword = cs.m_orclCredential.m_secureProxyPassword;
					}
					else
					{
						securePassword = cs.m_securedPassword;
						secureProxyPassword = cs.m_securedProxyPassword;
					}
				}
				m_oracleCommunication = new OracleCommunication(new ConOraBufPool(m_pm.m_oraBufPool));
				if (m_bClientInitiatedConnection)
				{
					m_oracleCommunication.ServerIs = "EMON";
				}
				m_oracleCommunication.ObCfgHT = ObCfgHT;
				m_oracleCommunication.ObTnsHT = ObTnsHT;
				m_oracleCommunication.ObLdpHT = ObLdpHT;
				if (!cs.m_pooling && connRefForCriteria != null)
				{
					m_oracleCommunication.ObCfgWL = connRefForCriteria.WalletLocationInternal;
				}
				else if (cs.m_pooling && m_pm != null)
				{
					m_oracleCommunication.ObCfgWL = m_pm.m_walletLocation;
				}
				if (!cs.m_pooling && connRefForCriteria != null && connRefForCriteria.KeepAlive)
				{
					m_oracleCommunication.KeepAlive = true;
					m_oracleCommunication.KeepAliveTime = connRefForCriteria.KeepAliveTime;
					m_oracleCommunication.KeepAliveInterval = connRefForCriteria.KeepAliveInterval;
				}
				else if (cs.m_pooling && m_pm != null && m_pm.m_bKeepAlive)
				{
					m_oracleCommunication.KeepAlive = true;
					m_oracleCommunication.KeepAliveTime = m_pm.m_keepAliveTime;
					m_oracleCommunication.KeepAliveInterval = m_pm.m_keepAliveInterval;
				}
				if (!flag)
				{
					flag = !m_pm.m_bNAEInUse.HasValue || m_pm.m_bNAEInUse.Value;
				}
				if (m_pm.m_bResolveTnsAlias)
				{
					try
					{
						m_pm.ResolveTnsAlias(m_pm.m_cs, m_oracleCommunication);
					}
					finally
					{
						m_pm.m_bResolveTnsAlias = false;
					}
				}
				if (!m_bClientInitiatedConnection)
				{
					m_oracleCommunication.InbandNotifier = InbandNotificationProcessing;
				}
				if (connRefForCriteria != null)
				{
					m_oracleCommunication.ShardingKeyB64 = connRefForCriteria.ShardingKeyB64;
					m_oracleCommunication.SuperShardingKeyB64 = connRefForCriteria.SuperShardingKeyB64;
					if (m_oracleCommunication.ShardingKeyB64 != null || m_oracleCommunication.SuperShardingKeyB64 != null)
					{
						instanceName = null;
					}
				}
				if (!m_bClientInitiatedConnection && m_pm.m_fullDescriptor != null && m_pm.m_fullDescriptor != string.Empty)
				{
					m_oracleCommunication.Connect(m_pm.m_fullDescriptor, flag, instanceName, m_pm.m_connOpt);
				}
				else
				{
					m_oracleCommunication.Connect(cs.m_dataSource, flag, instanceName);
				}
				if (!m_pm.m_bReadOnlyChunkOK.HasValue)
				{
					m_pm.m_bReadOnlyChunkOK = m_oracleCommunication.READONLY_CHUNK_OK;
				}
				if (!m_pm.m_bNAEInUse.HasValue)
				{
					m_pm.m_bNAEInUse = m_oracleCommunication.IsNAEInUse();
				}
				if (flag2 || !sqlNetOraConfig.WalletOverride)
				{
					if (cs.m_orclCredential != null)
					{
						if ((!cs.m_orclCredential.m_bUserIdSet && !cs.m_orclCredential.m_bProxyUserIdSet) || (cs.m_orclCredential.m_bProxyPasswordSet && !cs.m_orclCredential.m_bProxyUserIdSet) || (cs.m_orclCredential.m_bPasswordSet && !cs.m_orclCredential.m_bUserIdSet && cs.m_orclCredential.m_bProxyUserIdSet && cs.m_orclCredential.m_bProxyPasswordSet) || (cs.m_orclCredential.m_proxyUserId == "/" && !cs.m_orclCredential.m_bUserIdSet && cs.m_orclCredential.m_bPasswordSet))
						{
							throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
						}
					}
					else if ((!cs.m_bUserIdSet && !cs.m_bProxyUserIdSet) || (cs.m_bProxyPasswordSet && !cs.m_bProxyUserIdSet) || (cs.m_bPasswordSet && !cs.m_bUserIdSet && cs.m_bProxyUserIdSet && cs.m_bProxyPasswordSet) || (cs.m_proxyUserId == "/" && !cs.m_bUserIdSet && cs.m_bPasswordSet))
					{
						throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
					}
					if (cs.m_orclCredential != null)
					{
						if ((cs.m_orclCredential.m_userId != "/" || cs.m_orclCredential.m_bProxyUserIdSet || cs.m_orclCredential.m_bProxyPasswordSet) && ((!cs.m_orclCredential.m_bProxyUserIdSet && !cs.m_orclCredential.m_bPasswordSet) || (cs.m_orclCredential.m_bProxyUserIdSet && !cs.m_orclCredential.m_bProxyPasswordSet)) && cs.m_orclCredential.m_proxyUserId != "/")
						{
							throw new OracleException(1005, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1005));
						}
					}
					else if ((cs.m_userId != "/" || cs.m_bProxyUserIdSet || cs.m_bProxyPasswordSet) && ((!cs.m_bProxyUserIdSet && !cs.m_bPasswordSet) || (cs.m_bProxyUserIdSet && !cs.m_bProxyPasswordSet)) && cs.m_proxyUserId != "/")
					{
						throw new OracleException(1005, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1005));
					}
				}
				else if (m_cs.m_orclCredential != null)
				{
					if ("/" == m_cs.m_orclCredential.m_userId)
					{
						if (cs.m_orclCredential.m_bProxyPasswordSet && cs.m_orclCredential.m_bProxyUserIdSet)
						{
							throw new OracleException(28179, string.Empty, string.Empty, "ORA-28179: client user name not provided by proxy");
						}
						if (cs.m_orclCredential.m_bProxyUserIdSet)
						{
							throw new OracleException(1005, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1005));
						}
						if (cs.m_orclCredential.m_bProxyPasswordSet)
						{
							throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
						}
					}
				}
				else if ("/" == m_cs.m_userId)
				{
					if (cs.m_bProxyPasswordSet && cs.m_bProxyUserIdSet)
					{
						throw new OracleException(28179, string.Empty, string.Empty, "ORA-28179: client user name not provided by proxy");
					}
					if (cs.m_bProxyUserIdSet)
					{
						throw new OracleException(1005, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1005));
					}
					if (cs.m_bProxyPasswordSet)
					{
						throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
					}
				}
				m_oracleCommunication.OraBufPool.Init(m_oracleCommunication);
				if (m_oracleCommunication.m_sessionCtx != null && m_oracleCommunication.m_sessionCtx.m_sessionDataUnit != m_pm.m_oraBufPool.m_smallBufSize)
				{
					if (m_pm.m_oraBufPool.m_smallBufSize != 0)
					{
						m_pm.ClearAllPools(this);
					}
					m_pm.m_oraBufPool.UpdateBufSizes(m_oracleCommunication);
				}
				m_marshallingEngine = new MarshallingEngine(m_oracleCommunication, this);
				m_ttcSessionGet = new TTCSessionGet(m_marshallingEngine);
				if (string.Compare(m_oracleCommunication.Server, "POOLED", StringComparison.InvariantCultureIgnoreCase) == 0)
				{
					m_pm.m_cs.m_drcpEnabled = DrcpType.True;
					m_marshallingEngine.m_bDRCPConnection = true;
					if (connRefForCriteria != null)
					{
						m_drcpConnectionClass = connRefForCriteria.m_criteriaConnCls;
						if (connRefForCriteria.m_bCriteriaDrcpPurityNew == 1)
						{
							m_drcpSessionPurity = "1";
						}
					}
				}
				else
				{
					m_pm.m_cs.m_drcpEnabled = DrcpType.False;
					if (connRefForCriteria != null && !string.IsNullOrEmpty(connRefForCriteria.m_criteriaConnCls))
					{
						throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(-7601, "DRCPConnectionClass", "DRCP"));
					}
				}
				DoProtocolNegotiation();
				DoDataTypeNegotiation();
				if (m_ttcAuth != null)
				{
					m_ttcAuth.ReInit(m_marshallingEngine, m_pm.m_appThreadLCID);
				}
				double totalMilliseconds = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalMilliseconds;
				int hours = (int)(totalMilliseconds / 3600000.0);
				int minutes = (int)(totalMilliseconds / 60000.0 % 60.0);
				m_sessionTimeZone = new OracleIntervalDS(0, hours, minutes, 0, 0);
				bool flag3 = DoAuthentication(connRefForCriteria, userId, securePassword, proxyUserId, secureProxyPassword, connRefForCriteria?.m_secureNewPassword, flag2, bOpenEndUserSession);
				if (m_oracleCommunication.IsNAEInUse() && !flag3)
				{
					m_oracleCommunication.SetFoldInKey(m_ttcAuth.m_xoredKaAndKb);
				}
				m_bConnected = true;
				if (m_pm.m_cs.m_drcpEnabled == DrcpType.True && connRefForCriteria != null && !string.IsNullOrEmpty(connRefForCriteria.m_criteriaTag))
				{
					long s2cSessionFlags = 0L;
					AttachServerProcess(0L, bUseDRCPMultiTag: false, ref s2cSessionFlags);
					if ((s2cSessionFlags & 1) != 1)
					{
						bGotMatchingServerProcess = true;
					}
				}
				if (m_bClientInitiatedConnection)
				{
					return;
				}
				SendVersionMessageAndProcessResponse(connRefForCriteria);
				m_creationTime = DateTime.Now;
				m_marshallingEngine.DBVersion = m_ttcVersion.GetVersionNumber();
				SetAutoCommit(bAutoCommitOn: true);
				if (m_sessionProperties != null)
				{
					m_endUserSessionId = SessionId;
					m_endUserSerialNum = SerialNumber;
				}
				else
				{
					m_pxyUserSessionId = ProxySessionId;
					m_pxyUserSerialNum = ProxySerialNumber;
				}
				if (m_marshallingEngine.m_bDRCPConnection)
				{
					m_marshallingEngine.m_bDRCPSessionAttached = true;
					bDRCPServerProcessAttached = true;
				}
				if (ProviderConfig.m_bTraceLevelPrivate && m_pxyUserSessionId == -1)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, "(CON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")(TYPE=" + m_sessionType.ToString() + ")(CHRSET=" + m_serverCharacterSet + ":" + m_serverNCharSet + ")");
				}
				EvaluateDbMajorMinorPatchsetVersion();
				if (string.IsNullOrEmpty(m_pm.m_databaseDomainName))
				{
					m_pm.m_databaseDomainName = DatabaseDomainName;
					m_pm.SetDomainForDS(m_cs.ServerID, m_pm.m_databaseDomainName);
				}
				if (string.IsNullOrEmpty(m_pm.m_conStrServiceName))
				{
					string serviceName = ServiceName;
					if (!string.IsNullOrEmpty(serviceName) && serviceName != "null")
					{
						m_pm.m_conStrServiceName = serviceName;
						m_pm.SetServiceForDS(cs.ServerID, serviceName);
					}
				}
				BeginRequest();
				UpdateAttributes();
				if (m_pm.m_bSelfTuning)
				{
					if (!ProviderConfig.MaxStatementCacheSize.IsUserDefined)
					{
						if (!m_pm.m_maxOpenCursorsFetched)
						{
							int maxOpenCursors = MaxOpenCursors;
							int num = 20;
							if (maxOpenCursors > 0)
							{
								maxOpenCursors -= num;
								if (maxOpenCursors > 0)
								{
									m_pm.m_recommendedSCS = maxOpenCursors;
								}
							}
							m_pm.m_maxOpenCursorsFetched = true;
						}
					}
					else
					{
						m_pm.m_recommendedSCS = ProviderConfig.MaxStatementCacheSize.Value;
					}
				}
				else
				{
					m_pm.m_maxOpenCursorsFetched = true;
				}
				int recommendedSCS = m_pm.m_recommendedSCS;
				if (recommendedSCS > 0 && m_statementCache == null)
				{
					m_statementCache = new StatementCache(recommendedSCS);
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SelfTuning, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.connect, $"new StatementCache(stmtCacheSize)  executed for session id {SessionId} .. stmtcachesize is {recommendedSCS}");
				}
				if (OraclePool.m_bPerfHardConnectsPerSecond)
				{
					OraclePool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardConnectsPerSecond, this, m_cp);
				}
				if (m_executeSql != null)
				{
					m_executeSql.ReInit(m_marshallingEngine);
				}
				if (m_ttcSimplOp != null)
				{
					m_ttcSimplOp.ReInit(m_marshallingEngine);
				}
				if (m_ttcOPing != null)
				{
					m_ttcOPing.ReInit(m_marshallingEngine);
				}
				if (m_ttcClose != null)
				{
					m_ttcClose.ReInit(m_marshallingEngine);
				}
				if (m_ttcCancel != null)
				{
					m_ttcCancel.ReInit(m_marshallingEngine);
				}
				if (m_ttcSwitchSession != null)
				{
					m_ttcSwitchSession.ReInit(m_marshallingEngine);
				}
				if (m_ttcEndToEndMetrics != null)
				{
					m_ttcEndToEndMetrics.ReInit(m_marshallingEngine);
				}
				if (m_ttcNotification != null)
				{
					m_ttcNotification.ReInit(m_marshallingEngine);
				}
				if (m_ttcFetch != null)
				{
					m_ttcFetch.ReInit(m_marshallingEngine);
				}
				if (m_ttcTransactionSE != null)
				{
					m_ttcTransactionSE.ReInit(m_marshallingEngine);
				}
				if (m_ttcTransactionEN != null)
				{
					m_ttcTransactionEN.ReInit(m_marshallingEngine);
				}
				if (m_ttcSessionGet != null)
				{
					m_ttcSessionGet.ReInit(m_marshallingEngine);
				}
				if (m_ttcSessionRelease != null)
				{
					m_ttcSessionRelease.ReInit(m_marshallingEngine);
				}
				if (m_ttcSessState != null)
				{
					m_ttcSessState.ReInit(m_marshallingEngine);
				}
				bool haEvents = m_cs.m_haEvents;
				if (!m_cs.m_haEventsPresentInConnString)
				{
					haEvents = ConfigBaseClass.m_haEvents;
				}
				bool flag4 = false;
				bool flag5 = false;
				bool flag6 = false;
				string serviceName2 = ServiceName;
				string item = DatabaseDomainName + "|" + m_databaseName + "|" + ServiceName;
				if (haEvents && !dbsRegisteredForHA.Contains(item))
				{
					lock (m_lockForONSSubscriptions)
					{
						if (!dbsRegisteredForHA.Contains(item))
						{
							flag4 = true;
							dbsRegisteredForHA.Add(item);
						}
					}
				}
				bool loadBalancing = m_cs.m_loadBalancing;
				if (!m_cs.m_loadBalancingPresentInConnString)
				{
					loadBalancing = ConfigBaseClass.m_loadBalancing;
				}
				if (loadBalancing && !servicesRegisteredForRLB.Contains(item))
				{
					lock (m_lockForONSSubscriptions)
					{
						if (!servicesRegisteredForRLB.Contains(item))
						{
							flag5 = true;
							servicesRegisteredForRLB.Add(item);
						}
					}
				}
				if (connRefForCriteria != null && cs.m_pooling && (!string.IsNullOrEmpty(connRefForCriteria.ShardingKeyB64) || !string.IsNullOrEmpty(connRefForCriteria.SuperShardingKeyB64)) && !string.IsNullOrEmpty(serviceName2))
				{
					string[] array = serviceName2.Split(new char[1]
					{
						'.'
					});
					string text = string.Empty;
					if (array.Length >= 3)
					{
						text = array[^2];
					}
					if (!string.IsNullOrEmpty(text) && !shardDBRegisteredForChunk.Contains(text))
					{
						lock (m_lockForONSSubscriptions)
						{
							if (!shardDBRegisteredForChunk.Contains(text))
							{
								flag6 = true;
								shardDBRegisteredForChunk.Add(text);
							}
						}
					}
				}
				if (flag4 || flag5 || flag6)
				{
					ONSSubscriptionMetadata oNSSubscriptionMetadata = new ONSSubscriptionMetadata();
					oNSSubscriptionMetadata.m_domainName = DatabaseDomainName;
					oNSSubscriptionMetadata.m_serviceName = ServiceName;
					oNSSubscriptionMetadata.m_databaseName = m_databaseName;
					oNSSubscriptionMetadata.m_conTimeout = m_conTimeout;
					oNSSubscriptionMetadata.m_onsHASubscrPatter = m_onsHASubscrPatter;
					oNSSubscriptionMetadata.m_onsRLBSubscrPatter = m_onsRLBSubscPatter;
					oNSSubscriptionMetadata.m_onsConfigFromDb = m_onsConfigFromDb;
					oNSSubscriptionMetadata.m_bRegisterForHA = flag4;
					oNSSubscriptionMetadata.m_bRegisterForRLB = flag5;
					oNSSubscriptionMetadata.m_bREgisterForChunkMove = flag6;
					ThreadPool.QueueUserWorkItem(new WaitCallback(SubscribeONSEvents), oNSSubscriptionMetadata);
				}
				if (connRefForCriteria != null)
				{
					connRefForCriteria.m_bNewConCreated = true;
					m_connectionClass = connRefForCriteria.m_criteriaConnCls;
					m_pm.m_criteriaMapper.GetId(this);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, Trace.GetCPInfo(this, null, instanceName, "open"));
				}
			}
		}

		internal void StartSecureCQNListener(OraclePoolManager opm)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.StartSecureCQNListener);
			}
			try
			{
				m_bClientInitiatedConnection = true;
				m_pm = opm;
				m_cs = opm.m_cs;
				Connect(m_cs, bOpenEndUserSession: false, null);
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.StartSecureCQNListener, $"CQN Secure Listener Connection Established. CreationTime: {m_creationTime.ToString()}");
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.StartSecureCQNListener);
				}
			}
		}

		internal override void UpdateAttributes()
		{
			m_instanceName = InstanceName;
			m_hostName = HostName;
			m_databaseDomainName = DatabaseDomainName;
			m_databaseName = DatabaseUniqueName;
			m_maxIdentifierLength = MaxIdentifierLength;
			m_failoverType = FailoverTypeVal;
			m_onsConfigFromDb = OnsConfigFromDB;
			m_onsHASubscrPatter = OnsHASubscriberPattern;
			m_onsRLBSubscPatter = OnsRLBSubscriberPattern;
		}

		internal override bool AlterSession(bool[] alterConnectionTuple, OracleConnection connRefForCriteria)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AlterSession);
			}
			try
			{
				bool result = false;
				string text = "ALTER SESSION SET";
				if (m_bConnected)
				{
					lock (this)
					{
						if (m_bConnected)
						{
							if (alterConnectionTuple[0])
							{
								string defaultEditionName = GetDefaultEditionName();
								if (!string.IsNullOrEmpty(defaultEditionName))
								{
									text = text + " EDITION=\"" + defaultEditionName.Trim() + "\"";
								}
								if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaPdbName))
								{
									text = text + " CONTAINER=\"" + connRefForCriteria.m_criteriaPdbName.Trim().ToLowerInvariant() + "\"";
								}
								if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaServiceName))
								{
									text = text + " SERVICE=\"" + connRefForCriteria.m_criteriaServiceName.Trim().ToLowerInvariant() + "\"";
								}
								if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaEdition))
								{
									text = text + " EDITION=" + connRefForCriteria.m_criteriaEdition.Trim();
								}
							}
							else if (alterConnectionTuple[1])
							{
								if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaEdition))
								{
									text = text + " EDITION=" + connRefForCriteria.m_criteriaEdition.Trim();
								}
								else
								{
									string defaultEditionName2 = GetDefaultEditionName();
									if (!string.IsNullOrEmpty(defaultEditionName2))
									{
										text = text + " EDITION=\"" + defaultEditionName2.Trim() + "\"";
									}
								}
							}
							try
							{
								if (m_pm.m_cs.m_drcpEnabled == DrcpType.True)
								{
									PingServer();
								}
								PurgeStatementCache();
								if (ProviderConfig.m_bTraceLevelPrivate)
								{
									Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AlterSession, $" (ENTRY)  (MULTITENANT) ExecuteBasicSql({text}) using Conn ID = {m_endUserSessionId} , DBInst = {m_instanceName}");
								}
								ExecuteBasicSQL(text);
								result = true;
								UpdateAttributes();
								if (alterConnectionTuple[0])
								{
									bSessionSwitched = true;
									bool loadBalancing = m_cs.m_loadBalancing;
									if (!m_cs.m_loadBalancingPresentInConnString)
									{
										loadBalancing = ConfigBaseClass.m_loadBalancing;
									}
									string serviceName = ServiceName;
									bool flag = false;
									bool bRegisterForHA = false;
									if (loadBalancing && !servicesRegisteredForRLB.Contains(serviceName))
									{
										lock (m_lockForONSSubscriptions)
										{
											if (!servicesRegisteredForRLB.Contains(serviceName))
											{
												flag = true;
												servicesRegisteredForRLB.Add(serviceName);
											}
										}
									}
									if (flag)
									{
										ONSSubscriptionMetadata oNSSubscriptionMetadata = new ONSSubscriptionMetadata();
										oNSSubscriptionMetadata.m_serviceName = ServiceName;
										oNSSubscriptionMetadata.m_databaseName = m_databaseName;
										oNSSubscriptionMetadata.m_conTimeout = m_conTimeout;
										oNSSubscriptionMetadata.m_onsRLBSubscrPatter = m_onsRLBSubscPatter;
										oNSSubscriptionMetadata.m_onsConfigFromDb = m_onsConfigFromDb;
										oNSSubscriptionMetadata.m_bRegisterForHA = bRegisterForHA;
										oNSSubscriptionMetadata.m_bRegisterForRLB = flag;
										ThreadPool.QueueUserWorkItem(new WaitCallback(SubscribeONSEvents), oNSSubscriptionMetadata);
									}
								}
								else
								{
									bSessionSwitched = false;
								}
								if (alterConnectionTuple[1])
								{
									if (!string.IsNullOrEmpty(connRefForCriteria.m_criteriaEdition))
									{
										m_editionName = connRefForCriteria.m_criteriaEdition.Trim();
									}
									else
									{
										m_editionName = m_pm.m_defaultEditionDict[ServiceName];
									}
								}
							}
							catch (Exception innerException)
							{
								OracleException ex = new OracleException(-7505, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesg(-7505), innerException);
								OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AlterSession, ex);
								throw ex;
							}
						}
					}
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AlterSession);
				}
			}
		}

		internal static void SubscribeONSEvents(object state)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SubscribeONSEvents);
			}
			try
			{
				ONSSubscriptionMetadata oNSSubscriptionMetadata = (ONSSubscriptionMetadata)state;
				if (oNSSubscriptionMetadata == null)
				{
					return;
				}
				if (oNSSubscriptionMetadata.m_bRegisterForHA)
				{
					try
					{
						if (ProviderConfig.m_bTraceLevelPrivate)
						{
							Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)1310720, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Register_HA_RLB_Callbacks, $"Registering for HA notifications for (domain={oNSSubscriptionMetadata.m_domainName}) (database={oNSSubscriptionMetadata.m_databaseName}) (service={oNSSubscriptionMetadata.m_serviceName})");
						}
						OracleONSNotificationManager.GetNotificationManager(NotificationType.HA).RegisterForNotification(oNSSubscriptionMetadata.m_serviceName, oNSSubscriptionMetadata.m_databaseName, oNSSubscriptionMetadata.m_conTimeout, oNSSubscriptionMetadata.m_onsHASubscrPatter, oNSSubscriptionMetadata.m_onsConfigFromDb);
					}
					catch (Exception ex)
					{
						if (ProviderConfig.m_bTraceLevelPrivate)
						{
							Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)1310720, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SubscribeONSEvents, "Failed to Register for HA Events: " + ex);
						}
					}
				}
				if (oNSSubscriptionMetadata.m_bRegisterForRLB)
				{
					try
					{
						if (ProviderConfig.m_bTraceLevelPrivate)
						{
							Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)786432, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Register_HA_RLB_Callbacks, $"Registering for RLB notifications for (domain={oNSSubscriptionMetadata.m_domainName}) (database={oNSSubscriptionMetadata.m_databaseName}) (service={oNSSubscriptionMetadata.m_serviceName})");
						}
						OracleONSNotificationManager.GetNotificationManager(NotificationType.RLB).RegisterForNotification(oNSSubscriptionMetadata.m_serviceName, oNSSubscriptionMetadata.m_databaseName, oNSSubscriptionMetadata.m_conTimeout, oNSSubscriptionMetadata.m_onsRLBSubscrPatter, oNSSubscriptionMetadata.m_onsConfigFromDb);
					}
					catch (Exception ex2)
					{
						if (ProviderConfig.m_bTraceLevelPrivate)
						{
							Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)786432, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SubscribeONSEvents, "Failed to Register for RLB Events: " + ex2);
						}
					}
				}
				if (!oNSSubscriptionMetadata.m_bREgisterForChunkMove)
				{
					return;
				}
				try
				{
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, "Registring for Shard Chunk Move Notification for service: " + oNSSubscriptionMetadata.m_serviceName);
					}
					OracleONSNotificationManager.GetNotificationManager(NotificationType.ChunkMove).RegisterForNotification(oNSSubscriptionMetadata.m_serviceName, oNSSubscriptionMetadata.m_databaseName, oNSSubscriptionMetadata.m_conTimeout, null, oNSSubscriptionMetadata.m_onsConfigFromDb);
				}
				catch (Exception ex3)
				{
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Connect, "Failed to Register for Shard Chunk Move Notification Events: " + ex3);
					}
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SubscribeONSEvents);
				}
			}
		}

		internal void Logoff()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Logoff);
			}
			try
			{
				try
				{
					m_connectionFreeToUseEvent.WaitOne();
					AddAllPiggyBackRequests();
					TTCSimpleOperations simpleOperationsObject = SimpleOperationsObject;
					simpleOperationsObject.SetFunctionCode(9);
					simpleOperationsObject.WriteMessage();
					simpleOperationsObject.m_marshallingEngine.m_oraBufWriter.FlushData();
					simpleOperationsObject.ReadResponse();
				}
				finally
				{
					m_connectionFreeToUseEvent.Set();
				}
			}
			catch (Exception)
			{
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.Logoff);
				}
			}
		}

		internal void AlterSessionOnConnect(OracleConnection con)
		{
			OracleGlobalizationImpl oracleGlobalizationImpl = null;
			bool flag = ((con.m_majorVersion >= 12) ? true : false);
			if (m_cs.m_drcpEnabled != DrcpType.True && flag && m_oracleGlobalizationImpl == null)
			{
				if (m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl == null)
				{
					lock (m_pm.m_orclGlobLock)
					{
						if (m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl == null)
						{
							oracleGlobalizationImpl = new OracleGlobalizationImpl(m_pm.m_appThreadLCID);
							if (m_sessionProperties != null)
							{
								m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl = oracleGlobalizationImpl;
								GetGlobalizationValues(oracleGlobalizationImpl, con, flag);
							}
							else
							{
								m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl = oracleGlobalizationImpl;
								oracleGlobalizationImpl.AlterSession(oracleGlobalizationImpl, con);
							}
						}
						else
						{
							oracleGlobalizationImpl = m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl;
						}
					}
				}
				else
				{
					oracleGlobalizationImpl = m_pm.m_dictSvcCtx[ServiceName].m_orclGlobImpl;
				}
			}
			if (oracleGlobalizationImpl != null)
			{
				m_oracleGlobalizationImpl = (OracleGlobalizationImpl)oracleGlobalizationImpl.Clone();
			}
		}

		internal void GetGlobalizationValues(OracleGlobalizationImpl locGlobObj, OracleConnection con, bool isDB12101nAbove)
		{
			if (m_sessionProperties == null)
			{
				return;
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCCALENDAR"))
			{
				locGlobObj.m_calendar = (string)m_sessionProperties["AUTH_NLS_LXCCALENDAR"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCCURRENCY"))
			{
				locGlobObj.m_currency = (string)m_sessionProperties["AUTH_NLS_LXCCURRENCY"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCDATEFM"))
			{
				locGlobObj.m_dateFormat = (string)m_sessionProperties["AUTH_NLS_LXCDATEFM"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCDATELANG"))
			{
				locGlobObj.m_dateLanguage = (string)m_sessionProperties["AUTH_NLS_LXCDATELANG"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCUNIONCUR"))
			{
				locGlobObj.m_dualCurrency = (string)m_sessionProperties["AUTH_NLS_LXCUNIONCUR"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCISOCURR"))
			{
				locGlobObj.m_isoCurrency = (string)m_sessionProperties["AUTH_NLS_LXCISOCURR"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXLAN"))
			{
				locGlobObj.m_language = (string)m_sessionProperties["AUTH_NLS_LXLAN"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCNUMERICS"))
			{
				locGlobObj.m_numericCharacters = (string)m_sessionProperties["AUTH_NLS_LXCNUMERICS"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCSORT"))
			{
				locGlobObj.m_sort = (string)m_sessionProperties["AUTH_NLS_LXCSORT"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCTERRITORY"))
			{
				locGlobObj.m_territory = (string)m_sessionProperties["AUTH_NLS_LXCTERRITORY"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCSTMPFM"))
			{
				locGlobObj.m_timeStampFormat = (string)m_sessionProperties["AUTH_NLS_LXCSTMPFM"];
			}
			if (m_sessionProperties.ContainsKey("AUTH_NLS_LXCSTZNFM"))
			{
				locGlobObj.m_timeStampTZFormat = (string)m_sessionProperties["AUTH_NLS_LXCSTZNFM"];
			}
			if (m_sessionProperties.ContainsKey("SESSION_TIME_ZONE"))
			{
				locGlobObj.m_timeZone = (string)m_sessionProperties["SESSION_TIME_ZONE"];
			}
			if (isDB12101nAbove)
			{
				if (m_sessionProperties.ContainsKey("AL8KW_NLSCOMP"))
				{
					locGlobObj.m_comparison = (string)m_sessionProperties["AL8KW_NLSCOMP"];
				}
				if (m_sessionProperties.ContainsKey("SESSION_NLS_LXCNLSLENSEM"))
				{
					locGlobObj.m_lengthSemantics = (string)m_sessionProperties["SESSION_NLS_LXCNLSLENSEM"];
				}
				if (m_sessionProperties.ContainsKey("SESSION_NLS_LXCNCHAREXCP"))
				{
					locGlobObj.m_nCharConvException = bool.Parse((string)m_sessionProperties["SESSION_NLS_LXCNCHAREXCP"]);
				}
			}
			else
			{
				locGlobObj.SelectNLSValues(con);
			}
		}

		public override bool Dump()
		{
			if (m_oracleCommunication == null)
			{
				return false;
			}
			return true;
		}

		public override void DetachServerProcess(string drcpTagName, bool bUseDRCPMultiTag)
		{
			TTCSessionReleaseObject.ReleaseSession(drcpTagName, bUseDRCPMultiTag: false);
		}

		public override void AttachServerProcess(long sessionFlags, bool bUseDRCPMultiTag, ref long s2cSessionFlags)
		{
			TTCSessionGet tTCSessionGetObject = TTCSessionGetObject;
			tTCSessionGetObject.GetSession(0L, bUseDRCPMultiTag: false);
			s2cSessionFlags = tTCSessionGetObject.m_s2cSessionGetflags;
		}

		internal void NewDRCPSessionAttached()
		{
			if (m_statementCache != null)
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCSessionReturnValues, OracleTraceFuncName.NewDRCPSessionAttached, " Clear cursor_id from all statements in the cache: " + m_statementCache.Count);
				}
				m_statementCache.ClearAllCursorIds();
			}
		}

		public override void DisConnect(OracleConnection connRefForCriteria)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DisConnect, Trace.GetCPInfo(this, null, null, "kill"));
				if (m_pxyUserSessionId == -1)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DisConnect, "(DISCON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")");
				}
				else
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DisConnect, "(DISCON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")(PXYSID=" + m_pxyUserSessionId + ":" + m_pxyUserSerialNum + ")");
				}
			}
			try
			{
				if (m_deletionRequestor != DeletionRequestor.HA)
				{
					try
					{
						if (m_pm != null && m_pm.m_cs != null && m_pm.m_cs.m_drcpEnabled == DrcpType.True && bDRCPServerProcessAttached)
						{
							DetachServerProcess(null, bUseDRCPMultiTag: false);
							bDRCPServerProcessAttached = false;
							bGotMatchingServerProcess = false;
						}
						Logoff();
					}
					catch
					{
					}
				}
				try
				{
					m_oracleCommunication.Disconnect();
				}
				catch
				{
				}
				if (OraclePool.m_bPerfHardDisconnectsPerSecond)
				{
					OraclePool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this, m_cp);
				}
				m_oracleCommunication.OraBufPool.ReturnAll();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DisConnect, ex);
				throw;
			}
			finally
			{
				ClearState(m_deletionRequestor == DeletionRequestor.HA);
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DisConnect, Trace.GetCPInfo(this, null, null, "kill"));
				}
			}
		}

		internal void ClearState(bool isRequestFofHA)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ClearState);
			}
			try
			{
				m_bConnected = false;
				if (!isRequestFofHA)
				{
					m_oracleCommunication = null;
					m_marshallingEngine = null;
					m_statementCache = null;
					m_serverCompiletimeCapabilities = null;
					m_serverRuntimeCapabilities = null;
					m_cursorsToBeClosed.Clear();
					if (m_sessionProperties != null)
					{
						m_sessionProperties.Clear();
					}
					if (m_proxySessionProperties != null)
					{
						m_proxySessionProperties.Clear();
					}
					m_cursorsToBeCancelled.Clear();
					m_autoCommit = true;
					m_sessionType = SessionType.Non_Proxy;
					m_endOfCallStatus = 0L;
					m_serverCharacterSet = 0;
					m_serverNCharSet = 0;
					m_pxyUserSessionId = -1;
					m_pxyUserSerialNum = -1;
					m_endUserSessionId = -1;
					m_endUserSerialNum = -1;
					m_oracleGlobalizationImpl = null;
					m_temporaryLobReferences.Clear();
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ClearState, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ClearState);
				}
			}
		}

		internal void DoProtocolNegotiation()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoProtocolNegotiation);
			}
			try
			{
				if (m_protoNeg == null)
				{
					m_protoNeg = new TTCProtocolNegotiation(m_marshallingEngine);
				}
				else
				{
					m_protoNeg.ReInit(m_marshallingEngine);
				}
				m_marshallingEngine.m_typeRepresentation.m_representationArray[1] = 2;
				m_protoNeg.WriteMessage();
				m_protoNeg.m_marshallingEngine.m_oraBufWriter.FlushData();
				m_protoNeg.ReadResponse();
				m_serverCharacterSet = m_protoNeg.ServerCharacterSet;
				m_serverNCharSet = m_protoNeg.ServerNCharacterSet;
				m_marshallingEngine.m_typeRepresentation.m_serverConvFlags = m_protoNeg.ServerFlags;
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoProtocolNegotiation, "DoProtocolNegotiation : ServerCharSet = " + m_serverCharacterSet + ", ServerNCharSet = " + m_serverNCharSet + ", ServerFlags: " + m_protoNeg.ServerFlags);
				}
				m_serverCompiletimeCapabilities = m_protoNeg.ServerCompileTimeCapabilities;
				m_serverRuntimeCapabilities = m_protoNeg.ServerRunTimeCapabilities;
				m_marshallingEngine.m_dbCharSetConv = Conv.GetInstance(m_serverCharacterSet);
				m_marshallingEngine.m_nCharSetConv = Conv.GetInstance(m_serverNCharSet);
				short serverCharacterSet = m_serverCharacterSet;
				if (Conv.GetMaxBytesPerChar(m_serverCharacterSet) > 1)
				{
					m_marshallingEngine.m_bSvrCSMultibyte = true;
				}
				m_marshallingEngine.m_typeRepresentation.m_serverConvFlags |= 2;
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoProtocolNegotiation, "After Charset Negotiation : ServerCharSet = " + m_serverCharacterSet + ", ServerNCharSet = " + m_serverNCharSet + ", NetworkCharSet = " + serverCharacterSet + ", ServerConvFlags: " + m_marshallingEngine.m_typeRepresentation.m_serverConvFlags + ", Network CHARSET  MaxBytesPerChar = " + Conv.GetMaxBytesPerChar(serverCharacterSet), ", Server  CHARSET  MaxBytesPerChar = " + Conv.GetMaxBytesPerChar(m_serverCharacterSet), ", Server  NCHARSET MaxBytesPerChar = " + Conv.GetMaxBytesPerChar(m_serverNCharSet));
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoProtocolNegotiation, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoProtocolNegotiation);
				}
			}
		}

		internal void DoDataTypeNegotiation()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoDataTypeNegotiation);
			}
			try
			{
				if (m_dtyNeg == null)
				{
					m_dtyNeg = new TTCDataTypeNegotiation(m_marshallingEngine);
				}
				else
				{
					m_dtyNeg.ReInit(m_marshallingEngine);
				}
				m_dtyNeg.WriteMessage(m_serverCompiletimeCapabilities, m_serverRuntimeCapabilities, m_serverCharacterSet, m_serverNCharSet, m_marshallingEngine.m_typeRepresentation.m_serverConvFlags);
				m_dtyNeg.m_marshallingEngine.m_oraBufWriter.FlushData();
				m_dtyNeg.ReadResponse();
				if (m_dtyNeg.m_CompileTimeCapabilities[7] < m_serverCompiletimeCapabilities[7])
				{
					m_marshallingEngine.NegotiatedTTCVersion = m_dtyNeg.m_CompileTimeCapabilities[7];
				}
				else
				{
					m_marshallingEngine.NegotiatedTTCVersion = m_serverCompiletimeCapabilities[7];
				}
				m_b32kTypeSupported = m_dtyNeg.m_b32kTypeSupported;
				m_bSupportSessionStateOps = m_dtyNeg.m_bSupportSessionStateOps;
				if (((uint)m_serverCompiletimeCapabilities[15] & (true ? 1u : 0u)) != 0)
				{
					m_marshallingEngine.HasEOCSCapability = true;
				}
				if ((m_serverCompiletimeCapabilities[16] & 0x10u) != 0)
				{
					m_marshallingEngine.HasFSAPCapability = true;
				}
				if (m_serverCompiletimeCapabilities.Length > 37 && (m_serverCompiletimeCapabilities[37] & 0x20u) != 0)
				{
					m_marshallingEngine.m_bUseBigCLRChunks = true;
					m_marshallingEngine.m_effectiveTTCC_MXIN = 32767;
				}
				m_marshallingEngine.m_bServerUsingBigSCN = m_serverCompiletimeCapabilities[7] >= 8;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoDataTypeNegotiation, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoDataTypeNegotiation);
				}
			}
		}

		internal void SendVersionMessageAndProcessResponse(OracleConnection connRef)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SendVersionMessageAndProcessResponse);
			}
			try
			{
				if (m_ttcVersion == null)
				{
					m_ttcVersion = new TTCVersion(m_marshallingEngine);
				}
				else
				{
					m_ttcVersion.ReInit(m_marshallingEngine);
				}
				m_ttcVersion.WriteMessage();
				m_ttcVersion.m_marshallingEngine.m_oraBufWriter.FlushData();
				m_ttcVersion.ReadResponse();
				CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
				connRef?.CheckForWarnings(this);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SendVersionMessageAndProcessResponse, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SendVersionMessageAndProcessResponse);
				}
			}
		}

		internal bool DoAuthentication(OracleConnection connRefForCriteria, string userId, SecureString securePassword, string proxyUserId, SecureString secureProxyPassword, SecureString secureNewPassword, bool bDoExternalAuth, bool bOpenEndUserSession = true)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoAuthentication);
			}
			try
			{
				if (!string.IsNullOrEmpty(m_editionName) && (m_serverCompiletimeCapabilities == null || m_serverCompiletimeCapabilities.Length < 31 || (m_serverCompiletimeCapabilities[31] & 8) != 8))
				{
					OracleException innerException = new OracleException(-7500, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesg(-7500, "11g", "Edition Based Redefinition"));
					throw new OracleException(-7505, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesg(-7505), innerException);
				}
				bool flag = true;
				bool flag2 = false;
				TTCAuthenticate authenticateObject = AuthenticateObject;
				if ((m_cs.m_orclCredential != null && m_cs.m_orclCredential.m_bProxyUserIdSet) || m_cs.m_bProxyUserIdSet || (m_cs.m_orclCredential != null && m_cs.m_orclCredential.m_bProxyPasswordSet) || m_cs.m_bProxyPasswordSet)
				{
					m_sessionType = SessionType.Two_Session_Proxy;
					if ((m_cs.m_orclCredential == null || !m_cs.m_orclCredential.m_bPasswordSet) && !m_cs.m_bPasswordSet && !string.IsNullOrEmpty(userId))
					{
						m_sessionType = SessionType.Single_Session_Proxy;
					}
					flag2 = HandleProxyConection(connRefForCriteria, userId, securePassword, proxyUserId, secureProxyPassword, bDoExternalAuth, bOpenEndUserSession);
				}
				else
				{
					if (!string.IsNullOrEmpty(userId) || !bDoExternalAuth)
					{
						authenticateObject.WriteOSessKeyMessage(userId, m_logonMode);
						authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
						authenticateObject.ReadOSessKeyResponse();
						if ((0x20 & m_logonMode) != 0L || (0x40 & m_logonMode) != 0L)
						{
							if (12692 == m_marshallingEngine.TTCErrorObject.m_retCode)
							{
								CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
							}
							flag = false;
						}
						else
						{
							CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
						}
						connRefForCriteria?.CheckForWarnings(this);
					}
					else
					{
						flag = false;
					}
					if (secureNewPassword == null)
					{
						m_logonMode |= 1L;
					}
					else
					{
						m_logonMode |= 2L;
					}
					authenticateObject.WriteOAuthMessage(userId, securePassword, string.Empty, bProxyAuth: false, -1, -1, m_logonMode, secureNewPassword, m_serverCompiletimeCapabilities[4], !flag, bSendJDWP: true, m_protoNeg.ServerCharacterSet.ToString());
					authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
					flag2 = authenticateObject.ReceiveOAuthResponse();
					if (flag && flag2)
					{
						throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
					}
					CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
					m_sessionProperties = authenticateObject.m_sessionProperties;
					connRefForCriteria?.CheckForWarnings(this);
					m_sessionProperties = authenticateObject.m_sessionProperties;
				}
				return flag2;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoAuthentication, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.DoAuthentication);
				}
			}
		}

		internal void SetAutoCommit(bool bAutoCommitOn)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SetAutoCommit);
			}
			m_autoCommit = bAutoCommitOn;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.SetAutoCommit);
			}
		}

		internal void AddTempLOBsToBeFreed(byte[] lobLocator)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddTempLOBsToBeFreed);
			}
			lock (m_lockForLists)
			{
				if (!TTCLob.IsQuasiLocator(lobLocator))
				{
					m_tempLOBsToBeFreed.Add(lobLocator);
				}
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddTempLOBsToBeFreed);
			}
		}

		internal void AddCursorIdToBeClosed(long cursorId)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdToBeClosed);
			}
			if (cursorId > 0)
			{
				lock (m_lockForLists)
				{
					m_cursorsToBeClosed.Add(cursorId);
				}
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdToBeClosed);
			}
		}

		internal void AddCursorIdsToBeClosed(List<long> cursorIds)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdsToBeClosed);
			}
			lock (m_lockForLists)
			{
				foreach (long cursorId in cursorIds)
				{
					int num = (int)cursorId;
					if (num > 0)
					{
						m_cursorsToBeClosed.Add(num);
					}
				}
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdsToBeClosed);
			}
		}

		internal void AddCursorIdToBeCancelled(long cursorId)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdToBeCancelled);
			}
			if (cursorId > 0)
			{
				lock (m_lockForLists)
				{
					m_cursorsToBeCancelled.Add(cursorId);
				}
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddCursorIdToBeCancelled);
			}
		}

		internal void FlushPendingPiggybackMessages()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FlushPendingPiggybackMessages);
			}
			try
			{
				bool flag = false;
				lock (m_lockForLists)
				{
					if (m_tempLOBsToBeFreed.Count > 0 || m_cursorsToBeClosed.Count > 0 || m_cursorsToBeCancelled.Count > 0 || m_endToEndMetricsModified[2] || m_endToEndMetricsModified[0] || m_endToEndMetricsModified[1] || m_endToEndMetricsModified[3])
					{
						flag = true;
					}
				}
				if (flag)
				{
					PingServer();
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FlushPendingPiggybackMessages, ex);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.FlushPendingPiggybackMessages);
				}
			}
		}

		internal override void BeginRequest()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.BeginRequest);
			}
			m_bRequestBoundaryToBeSet = true;
			m_bSetRequestBoundaryPiggybackSent = false;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.BeginRequest);
			}
		}

		internal override void EndRequest()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.EndRequest);
			}
			m_bRequestBoundaryToBeReset = true;
			m_bSetRequestBoundaryPiggybackSent = false;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.EndRequest);
			}
		}

		internal void AddRequestBoundaryPiggyback()
		{
			if (m_bSetRequestBoundaryPiggybackSent || (!m_bRequestBoundaryToBeSet && !m_bRequestBoundaryToBeReset))
			{
				return;
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddRequestBoundaryPiggyback);
			}
			try
			{
				long num = 0L;
				TTCSessionState sessionStateObject = SessionStateObject;
				if (m_bRequestBoundaryToBeSet)
				{
					num |= 4;
					m_bRequestBoundaryToBeSet = false;
				}
				else if (m_bRequestBoundaryToBeReset)
				{
					num |= 8;
					m_bRequestBoundaryToBeReset = false;
				}
				sessionStateObject.AddAsPiggyback(num);
			}
			finally
			{
				m_bSetRequestBoundaryPiggybackSent = true;
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddRequestBoundaryPiggyback);
				}
			}
		}

		internal void SetShardingInfoForPiggyback(string shardingKey, string superShardingKey, string chunkName)
		{
			m_shardingKey = shardingKey;
			m_superShardingKey = superShardingKey;
			m_chunkName = chunkName;
			if (!string.IsNullOrEmpty(m_shardingKey) || !string.IsNullOrEmpty(m_superShardingKey) || !string.IsNullOrEmpty(m_chunkName))
			{
				m_sendShardingInfoPiggyback = true;
			}
			else
			{
				m_sendShardingInfoPiggyback = false;
			}
		}

		internal void AddAllPiggyBackRequests(bool ensureCleanChannel = true)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddAllPiggyBackRequests);
			}
			try
			{
				if (ensureCleanChannel && m_oracleCommunication.InBreakResetMode())
				{
					m_marshallingEngine.ProcessReset();
				}
				if (!m_bSetRequestBoundaryPiggybackSent && CanSendRequestBoundary)
				{
					AddRequestBoundaryPiggyback();
				}
				if (m_sendShardingInfoPiggyback)
				{
					TTCChunkInfoObject.AddAsPiggyback(m_shardingKey, m_superShardingKey, m_chunkName);
					m_sendShardingInfoPiggyback = false;
				}
				lock (m_lockForLists)
				{
					if (m_tempLOBsToBeFreed.Count > 0)
					{
						TTCLob.FreeTempLobsPiggyBack(m_marshallingEngine, m_tempLOBsToBeFreed);
						m_tempLOBsToBeFreed.Clear();
					}
					if (m_cursorsToBeClosed.Count > 0)
					{
						TTCCloseObject.Write(m_cursorsToBeClosed);
						m_cursorsToBeClosed.Clear();
					}
					if (m_cursorsToBeCancelled.Count > 0)
					{
						TTCCancelObject.Write(m_cursorsToBeCancelled);
						m_cursorsToBeCancelled.Clear();
					}
					if (m_endToEndMetricsModified[2] || m_endToEndMetricsModified[0] || m_endToEndMetricsModified[1] || m_endToEndMetricsModified[3])
					{
						TTCEndToEndMetricsObject.Write(m_endToEndMetrics, m_endToEndMetricsModified);
						m_endToEndMetricsModified[2] = false;
						m_endToEndMetricsModified[0] = false;
						m_endToEndMetricsModified[1] = false;
						m_endToEndMetricsModified[3] = false;
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddAllPiggyBackRequests, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.AddAllPiggyBackRequests);
				}
			}
		}

		internal void ResetEndToEndMetrics()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ResetEndToEndMetrics);
			}
			try
			{
				m_endToEndMetrics[2] = null;
				m_endToEndMetrics[0] = null;
				m_endToEndMetrics[1] = null;
				m_endToEndMetrics[3] = null;
				m_endToEndMetricsModified[2] = true;
				m_endToEndMetricsModified[0] = true;
				m_endToEndMetricsModified[1] = true;
				m_endToEndMetricsModified[3] = true;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ResetEndToEndMetrics, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ResetEndToEndMetrics);
				}
			}
		}

		internal void ResetMTSTxnCtx()
		{
			if (m_mtsTxnCtx != null)
			{
				m_mtsTxnCtx.Reset(this);
			}
		}

		internal string GetServerVersion()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetServerVersion);
			}
			try
			{
				return m_pm.m_serverVersion;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetServerVersion, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetServerVersion);
				}
			}
		}

		internal void EvaluateDbMajorMinorPatchsetVersion()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.EvaluateDbMajorMinorPatchsetVersion);
			}
			try
			{
				m_pm.m_serverVersion = TTCAuthenticate.ConvertVersionIntToString(m_marshallingEngine, (int)m_ttcVersion.m_retVersionNumber, ref m_dbMajorVersion, ref m_dbMinorVersion, ref m_dbPatchsetVersion);
				if (m_dbMajorVersion > 10 || (m_dbMajorVersion == 10 && m_dbMinorVersion >= 2))
				{
					m_isDb10gR2OrHigher = true;
				}
				if (m_dbMajorVersion > 11 || (m_dbMajorVersion == 11 && m_dbMinorVersion >= 1))
				{
					m_isDb11gR1OrHigher = true;
				}
				if (m_dbMajorVersion > 12 || (m_dbMajorVersion == 12 && m_dbMinorVersion >= 1))
				{
					m_isDb12cR1OrHigher = true;
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.EvaluateDbMajorMinorPatchsetVersion, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.EvaluateDbMajorMinorPatchsetVersion);
				}
			}
		}

		internal static void CheckForAnyErrorFromDB(TTCError ttcOER)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CheckForAnyErrorFromDB);
			}
			if (ttcOER.ErrorCode != 0)
			{
				byte[] errorMessage = ttcOER.ErrorMessage;
				char[] t = ttcOER.m_marshallingEngine.m_charArrayPooler.Dequeue();
				string errMsg = ttcOER.m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(errorMessage, 0, errorMessage.Length, t);
				ttcOER.m_marshallingEngine.m_charArrayPooler.Enqueue(ref t);
				throw new OracleException(ttcOER.ErrorCode, string.Empty, string.Empty, errMsg);
			}
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CheckForAnyErrorFromDB);
			}
		}

		internal OracleTimeZoneInfo? GetDBTimeZoneBytes()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetDBTimeZoneBytes);
			}
			try
			{
				if (m_dtyNeg != null)
				{
					if (!m_dbTimeZoneInfo.HasValue)
					{
						m_dbTimeZoneInfo = TimeStamp.GetTimeZoneInfo(m_dtyNeg.m_dbTimeZoneBytes);
					}
					return m_dbTimeZoneInfo;
				}
				return null;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetDBTimeZoneBytes);
				}
			}
		}

		private bool HandleProxyConection(OracleConnection connRef, string userId, SecureString securePassword, string proxyUserId, SecureString secureProxyPassword, bool bDoExternalAuth, bool bOpenEndUserSession)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.HandleProxyConection);
			}
			try
			{
				bool result = OpenProxySession(connRef, userId, proxyUserId, secureProxyPassword, bDoExternalAuth, !string.IsNullOrEmpty(proxyUserId));
				if (bOpenEndUserSession && SessionType.Two_Session_Proxy == m_sessionType)
				{
					OpenEndUserSession(userId, securePassword, connRef);
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.HandleProxyConection, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.HandleProxyConection);
				}
			}
		}

		private bool OpenProxySession(OracleConnection connRefForCriteria, string userId, string proxyUserId, SecureString secureProxyPassword, bool bDoExternalAuth, bool bVerifyResponseFromServer)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenProxySession);
			}
			try
			{
				bool flag = false;
				TTCAuthenticate authenticateObject = AuthenticateObject;
				if (!string.IsNullOrEmpty(proxyUserId) || !bDoExternalAuth)
				{
					authenticateObject.WriteOSessKeyMessage(proxyUserId, m_logonMode);
					authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
					authenticateObject.ReadOSessKeyResponse();
					CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
					connRefForCriteria?.CheckForWarnings(this);
				}
				m_logonMode |= 1L;
				string proxyClientName = string.Empty;
				if (SessionType.Single_Session_Proxy == m_sessionType)
				{
					proxyClientName = userId;
				}
				authenticateObject.WriteOAuthMessage(proxyUserId, secureProxyPassword, proxyClientName, bProxyAuth: false, -1, -1, m_logonMode, null, m_serverCompiletimeCapabilities[4], !bVerifyResponseFromServer, (SessionType.Single_Session_Proxy == m_sessionType) ? true : false, m_protoNeg.ServerCharacterSet.ToString());
				authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
				flag = authenticateObject.ReceiveOAuthResponse();
				if (bVerifyResponseFromServer && flag)
				{
					throw new OracleException(1017, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(1017));
				}
				CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
				connRefForCriteria?.CheckForWarnings(this);
				m_proxySessionProperties = authenticateObject.m_sessionProperties;
				m_pxyUserSessionId = ProxySessionId;
				m_pxyUserSerialNum = ProxySerialNumber;
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenProxySession, "(CON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")(PXYSID=" + m_pxyUserSessionId + ":" + m_pxyUserSerialNum + ")(TYPE=" + m_sessionType.ToString() + ")(CHRSET=" + m_serverCharacterSet + ":" + m_serverNCharSet + ")");
				}
				return flag;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenProxySession, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenProxySession);
				}
			}
		}

		internal void OpenEndUserSession(string userId, SecureString securePassword, OracleConnection connRefForCriteria)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenEndUserSession);
			}
			bool flag = false;
			try
			{
				if (connRefForCriteria != null && !string.IsNullOrEmpty(connRefForCriteria.m_criteriaEdition))
				{
					m_editionName = connRefForCriteria.m_criteriaEdition;
				}
				TTCAuthenticate authenticateObject = AuthenticateObject;
				authenticateObject.ReInit(authenticateObject.m_marshallingEngine);
				if (!string.IsNullOrEmpty(userId))
				{
					authenticateObject.WriteOSessKeyMessage(userId, m_logonMode);
					authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
					authenticateObject.ReadOSessKeyResponse();
					CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
					connRefForCriteria?.CheckForWarnings(this);
					flag = true;
				}
				authenticateObject.WriteOAuthMessage(userId, securePassword, string.Empty, bProxyAuth: true, m_pxyUserSessionId, m_pxyUserSerialNum, m_logonMode, null, m_serverCompiletimeCapabilities[4], !flag, bSendJDWP: true, m_protoNeg.ServerCharacterSet.ToString());
				authenticateObject.m_marshallingEngine.m_oraBufWriter.FlushData();
				authenticateObject.ReceiveOAuthResponse();
				CheckForAnyErrorFromDB(m_marshallingEngine.TTCErrorObject);
				connRefForCriteria?.CheckForWarnings(this);
				m_sessionProperties = authenticateObject.m_sessionProperties;
				m_endUserSessionId = SessionId;
				m_endUserSerialNum = SerialNumber;
				TTCSwitchSessionObject.Write(m_endUserSessionId, m_endUserSerialNum, TTCSwitchSession.OSESSWS);
				m_sessionType = SessionType.Two_Session_Proxy;
				m_bEndUserSessionEstablished = true;
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenEndUserSession, "(CON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")(PXYSID=" + m_pxyUserSessionId + ":" + m_pxyUserSerialNum + ")(TYPE=" + m_sessionType.ToString() + ")(CHRSET=" + m_serverCharacterSet + ":" + m_serverNCharSet + ")");
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenEndUserSession, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.OpenEndUserSession);
				}
			}
		}

		internal void CloseEndUserSession()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CloseEndUserSession);
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.CP, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CloseEndUserSession, "(DISCON) (ENDSID=" + m_endUserSessionId + ":" + m_endUserSerialNum + ")");
			}
			m_bEndUserSessionEstablished = false;
			try
			{
				Logoff();
				TTCSwitchSessionObject.Write(m_pxyUserSessionId, m_pxyUserSerialNum, TTCSwitchSession.OSESSWS);
				m_sessionProperties = m_proxySessionProperties;
				m_sessionType = SessionType.Non_Proxy;
				if (m_ElementAttributeTokens != null)
				{
					m_ElementAttributeTokens.Purge();
					m_ElementAttributeTokens = null;
				}
				if (m_NamespaceTokens != null)
				{
					m_NamespaceTokens.Purge();
					m_NamespaceTokens = null;
				}
				DisposeDecodeStream();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CloseEndUserSession, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.CloseEndUserSession);
				}
			}
		}

		internal string GetCorrespondingAuthAttrName(int keyword)
		{
			return keyword switch
			{
				0 => "AUTH_NLS_LXCCURRENCY", 
				1 => "AUTH_NLS_LXCISOCURR", 
				2 => "AUTH_NLS_LXCNUMERICS", 
				7 => "AUTH_NLS_LXCDATEFM", 
				8 => "AUTH_NLS_LXCDATELANG", 
				9 => "AUTH_NLS_LXCTERRITORY", 
				10 => "SESSION_NLS_LXCCHARSET", 
				11 => "AUTH_NLS_LXCSORT", 
				12 => "AUTH_NLS_LXCCALENDAR", 
				16 => "AUTH_NLS_LXLAN", 
				50 => "AL8KW_NLSCOMP", 
				52 => "AUTH_NLS_LXCUNIONCUR", 
				57 => "AUTH_NLS_LXCTIMEFM", 
				58 => "AUTH_NLS_LXCSTMPFM", 
				59 => "AUTH_NLS_LXCTTZNFM", 
				60 => "AUTH_NLS_LXCSTZNFM", 
				61 => "SESSION_NLS_LXCNLSLENSEM", 
				62 => "SESSION_NLS_LXCNCHAREXCP", 
				63 => "SESSION_NLS_LXCNCHARIMP", 
				_ => string.Empty, 
			};
		}

		internal void UpdateSessionAttributes(TTCKeywordValuePair[] al8KeyVals, Hashtable sProperties)
		{
			if (al8KeyVals == null || al8KeyVals.Length == 0)
			{
				return;
			}
			Hashtable hashtable = ((sProperties != null) ? sProperties : ((SessionType.Single_Session_Proxy != m_sessionType) ? m_sessionProperties : m_proxySessionProperties));
			int num = 0;
			byte[] array = null;
			for (int i = 0; i < al8KeyVals.Length; i++)
			{
				try
				{
					num = al8KeyVals[i].m_keyword;
					array = al8KeyVals[i].m_binaryValue;
					switch (num)
					{
					case 0:
					case 1:
					case 2:
					case 7:
					case 8:
					case 9:
					case 10:
					case 11:
					case 12:
					case 16:
					case 50:
					case 52:
					case 57:
					case 58:
					case 59:
					case 60:
					case 61:
					case 62:
					case 63:
					{
						string correspondingAuthAttrName = m_marshallingEngine.m_connImplReference.GetCorrespondingAuthAttrName(num);
						if (!string.IsNullOrEmpty(correspondingAuthAttrName))
						{
							if (array != null)
							{
								hashtable[correspondingAuthAttrName.Trim()] = m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(array, 0, array.Length);
							}
							else if (al8KeyVals[i].m_textValueInString != null)
							{
								hashtable[correspondingAuthAttrName.Trim()] = al8KeyVals[i].m_textValueInString;
							}
						}
						break;
					}
					case 163:
					{
						m_sessionTimeZone = new OracleIntervalDS(array);
						m_sessionTimeZone.initialZoneId = 0;
						string arg = Math.Abs(m_sessionTimeZone.Hours).ToString("00", CultureInfo.InvariantCulture);
						string arg2 = Math.Abs(m_sessionTimeZone.Minutes).ToString("00", CultureInfo.InvariantCulture);
						string arg3 = ((m_sessionTimeZone.Hours >= 0) ? "+" : "-");
						hashtable["SESSION_TIME_ZONE"] = $"{arg3}{arg}:{arg2}";
						break;
					}
					case 165:
					{
						string empty = string.Empty;
						if (array != null)
						{
							empty = (string)(hashtable["AUTH_SESSION_ID"] = m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(array, 0, array.Length));
						}
						break;
					}
					case 166:
					{
						string empty2 = string.Empty;
						if (array != null)
						{
							empty2 = (string)(hashtable["AUTH_SERIAL_NUM"] = m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(array, 0, array.Length));
						}
						break;
					}
					case 168:
						if (al8KeyVals[i].m_textValueInString != null)
						{
							hashtable["AL8KW_SCHEMA_NAME"] = al8KeyVals[i].m_textValueInString.Trim();
						}
						break;
					case 169:
						if (array != null && array.Length >= 4)
						{
							int num6 = array[3];
							num6 |= array[2] << 8;
							num6 |= array[1] << 16;
							hashtable["AL8KW_SCHEMA_ID"] = (num6 | (array[0] << 24)).ToString();
						}
						break;
					case 172:
						if (al8KeyVals[i].m_textValueInString != null)
						{
							hashtable["AUTH_ORA_EDITION"] = al8KeyVals[i].m_textValueInString;
							m_editionName = al8KeyVals[i].m_textValueInString;
						}
						break;
					case 175:
						if (array != null && array.Length >= 4)
						{
							int num2 = array[3];
							num2 |= array[2] << 8;
							num2 |= array[1] << 16;
							hashtable["AUTH_MAX_OPEN_CURSORS"] = (num2 | (array[0] << 24)).ToString();
						}
						break;
					case 176:
					{
						int num7 = 0;
						if (array != null && array.Length >= 4)
						{
							num7 = array[3];
							num7 |= array[2] << 8;
							num7 |= array[1] << 16;
							PDBUniqueId = (num7 | (array[0] << 24)).ToString();
						}
						break;
					}
					case 177:
					{
						long num4 = 0L;
						if (array != null)
						{
							for (int num5 = 3; num5 >= 0; num5--)
							{
								num4 |= (long)(((ulong)array[3 - num5] & 0xFFuL) << 8 * num5);
							}
							DatabaseId = num4.ToString();
						}
						break;
					}
					case 182:
						if (array != null && array.Length >= 4)
						{
							int num3 = array[3];
							num3 |= array[2] << 8;
							num3 |= array[1] << 16;
							num3 |= array[0] << 24;
							hashtable["AUTH_MAX_IDEN_LENGTH"] = num3.ToString();
							m_maxIdentifierLength = num3;
						}
						break;
					case 183:
						if (al8KeyVals[i].m_textValueInString != null)
						{
							hashtable["AUTH_SC_SERVICE_NAME"] = al8KeyVals[i].m_textValueInString;
						}
						break;
					case 197:
						if (al8KeyVals[i].m_textValueInString != null)
						{
							hashtable["AL8KW_CONTAINER_NAME"] = al8KeyVals[i].m_textValueInString;
						}
						break;
					}
				}
				catch (Exception ex)
				{
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.UpdateSessionAttributes, "Failed to Parse Keyword: " + num);
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.UpdateSessionAttributes, ex.ToString());
					}
				}
			}
		}

		internal override void GetConStrDefaults()
		{
			if (m_pm.m_bDefaultsFetched)
			{
				return;
			}
			lock (m_pm.m_conStrDefaultsLocker)
			{
				if (m_pm.m_bDefaultsFetched)
				{
					return;
				}
				if (m_isDb12cR1OrHigher)
				{
					string text = null;
					OracleCommandImpl oracleCommandImpl = null;
					oracleCommandImpl = getCommandImpl();
					oracleCommandImpl.m_addRowid = false;
					oracleCommandImpl.m_addToStatementCache = false;
					oracleCommandImpl.m_arrayBindCount = 0;
					oracleCommandImpl.m_bBindByName = false;
					oracleCommandImpl.m_fetchSize = ConfigBaseClass.m_FetchSize;
					OracleParameterCollection oracleParameterCollection = new OracleParameterCollection();
					OracleParameter oracleParameter = null;
					text = "DECLARE\n\n                          BEGIN\n                             select sys_context('USERENV','CON_NAME') into :PDBNAME from dual;                             \n                          END;\n                          ";
					oracleParameter = new OracleParameter("PDBNAME", OracleDbType.Varchar2, 256, "", ParameterDirection.Output);
					oracleParameterCollection.Add(oracleParameter);
					TTCError tTCErrorObject = m_marshallingEngine.TTCErrorObject;
					try
					{
						m_marshallingEngine.TTCErrorObject = new TTCError(m_marshallingEngine);
						ExecuteNonQueryWithBind(oracleCommandImpl, text, oracleParameterCollection, CommandType.Text);
					}
					finally
					{
						m_marshallingEngine.TTCErrorObject = tTCErrorObject;
					}
					if (m_isDb12cR1OrHigher && oracleParameter != null && oracleParameter.Value != null && string.IsNullOrEmpty(m_pm.m_conStrPdbName))
					{
						m_pm.m_conStrPdbName = oracleParameter.Value.ToString()!.ToLowerInvariant();
					}
				}
				m_pm.m_bDefaultsFetched = true;
			}
		}

		internal override string GetDefaultEditionName()
		{
			string result = null;
			if (m_isDb11gR1OrHigher)
			{
				lock (m_pm.m_defaultEditionLocker)
				{
					if (!m_pm.m_defaultEditionDict.ContainsKey(ServiceName))
					{
						string text = null;
						OracleCommandImpl oracleCommandImpl = null;
						oracleCommandImpl = getCommandImpl();
						oracleCommandImpl.m_addRowid = false;
						oracleCommandImpl.m_addToStatementCache = false;
						oracleCommandImpl.m_arrayBindCount = 0;
						oracleCommandImpl.m_bBindByName = false;
						oracleCommandImpl.m_fetchSize = ConfigBaseClass.m_FetchSize;
						OracleParameterCollection oracleParameterCollection = new OracleParameterCollection();
						OracleParameter oracleParameter = null;
						text = "DECLARE\n\n                          BEGIN \n                             SELECT PROPERTY_VALUE into :EDITIONNAME FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME = 'DEFAULT_EDITION';                        \n                          END;\n                          ";
						oracleParameter = new OracleParameter("EDITIONNAME", OracleDbType.Varchar2, 256, "", ParameterDirection.Output);
						oracleParameterCollection.Add(oracleParameter);
						TTCError tTCErrorObject = m_marshallingEngine.TTCErrorObject;
						try
						{
							m_marshallingEngine.TTCErrorObject = new TTCError(m_marshallingEngine);
							ExecuteNonQueryWithBind(oracleCommandImpl, text, oracleParameterCollection, CommandType.Text);
						}
						finally
						{
							m_marshallingEngine.TTCErrorObject = tTCErrorObject;
						}
						if (oracleParameter != null && oracleParameter.Value != null)
						{
							m_pm.m_defaultEditionDict[ServiceName] = oracleParameter.Value.ToString();
						}
					}
					return m_pm.m_defaultEditionDict[ServiceName];
				}
			}
			return result;
		}

		private int ExecuteNonQueryWithBind(OracleCommandImpl cmdImpl, string cmdText, OracleParameterCollection m_parameters, CommandType m_commandType)
		{
			int result = 0;
			OracleException exceptionForArrayBindDML = null;
			OracleLogicalTransaction oracleLogicalTransaction = null;
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExecuteNonQueryWithBind);
			}
			try
			{
				cmdImpl.m_cancelExecutionEvent.Reset();
				cmdImpl.m_continueCancel.Reset();
				cmdImpl.m_bServerExecutionComplete = false;
				OracleParameterCollection bindByPositionParamColl = null;
				bool bBindParamPresent = true;
				Timer timer = null;
				long[] scnFromExecution;
				try
				{
					OracleDependencyImpl orclDependencyImpl = null;
					result = cmdImpl.ExecuteNonQuery(cmdText, m_parameters, m_commandType, this, 0, 0L, orclDependencyImpl, out scnFromExecution, out bindByPositionParamColl, ref bBindParamPresent, out exceptionForArrayBindDML, null, ref oracleLogicalTransaction);
				}
				finally
				{
					if (timer != null)
					{
						timer.Change(-1L, -1L);
						timer.Dispose();
					}
				}
				if (bBindParamPresent)
				{
					if (m_parameters != null)
					{
						if (m_parameters.Count > 0)
						{
							ExtractAccessorValuesIntoParam(cmdImpl, bindByPositionParamColl, this, bindByPositionParamColl.Count, cmdText, 0L, 0L, 0L, scnFromExecution, bCallFromExecuteReader: false);
							return result;
						}
						return result;
					}
					return result;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExecuteNonQueryWithBind, ex, oracleLogicalTransaction);
				if (ex is OracleException)
				{
					if (((OracleException)ex).OracleLogicalTransaction == null || ((OracleException)ex).OracleLogicalTransaction.UserCallCompleted != true || ((OracleException)ex).OracleLogicalTransaction.Committed != true)
					{
						throw;
					}
					return result;
				}
				throw;
			}
			finally
			{
				if (cmdImpl != null)
				{
					cmdImpl.m_bindAccessors = null;
				}
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExecuteNonQueryWithBind);
				}
			}
		}

		internal void ExtractAccessorValuesIntoParam(OracleCommandImpl cmdImpl, OracleParameterCollection paramColl, OracleConnectionImpl connImpl, int paramCount, string commandText, long longFetchSize, long clientInitialLOBFS, long internalInitialLOBFS, long[] scnFromExecution, bool bCallFromExecuteReader)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExtractAccessorValuesIntoParam);
			}
			int num = 0;
			Accessor accessor = null;
			char[] array = null;
			BindDirection[] bindDirectionsFromServer = cmdImpl.m_bindDirectionsFromServer;
			Accessor[] bindAccessors = cmdImpl.m_bindAccessors;
			try
			{
				for (int i = 0; i < paramCount; i++)
				{
					OracleParameter oracleParameter = paramColl[i];
					if (oracleParameter.m_bDuplicateBind)
					{
						continue;
					}
					if (bindDirectionsFromServer[num] != BindDirection.Input)
					{
						accessor = bindAccessors[num];
						switch (oracleParameter.OracleDbType)
						{
						case OracleDbType.Char:
						case OracleDbType.Long:
						case OracleDbType.NChar:
						case OracleDbType.NVarchar2:
						case OracleDbType.Varchar2:
							if (array == null)
							{
								array = m_marshallingEngine.m_charArrayPooler.Dequeue();
							}
							oracleParameter.PostBind_Char(this, accessor, array);
							break;
						default:
							oracleParameter.Value = accessor.GetValue();
							break;
						}
						accessor.Initialize();
					}
					num++;
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExtractAccessorValuesIntoParam, ex);
				throw;
			}
			finally
			{
				if (array != null)
				{
					m_marshallingEngine.m_charArrayPooler.Enqueue(array);
				}
				if (m_marshallingEngine.m_oraBufRdr != null)
				{
					m_marshallingEngine.m_oraBufRdr.FreeTempOBList();
				}
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.ExtractAccessorValuesIntoParam);
				}
			}
		}

		internal void PurgeStatementCache(int targetSize = 0)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PurgeStatementCache);
			}
			try
			{
				if (m_statementCache != null && m_statementCache.Count > targetSize)
				{
					List<long> list = m_statementCache.Purge(targetSize);
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						string text = $"Purging Stmt Cache to <{targetSize}> size, Closing <{list.Count}> cursors.";
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.SvcObj, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PurgeStatementCache, text);
					}
					if (list.Count > 0)
					{
						AddCursorIdsToBeClosed(list);
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PurgeStatementCache, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.PurgeStatementCache);
				}
			}
		}

		internal bool GetLastWarning(out string warningMsg, out int errorCode)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetLastWarning);
			}
			try
			{
				warningMsg = null;
				errorCode = -1;
				if (m_marshallingEngine == null)
				{
					return false;
				}
				errorCode = m_marshallingEngine.TTCErrorObject.ErrorCode;
				if (m_marshallingEngine.TTCErrorObject.m_TTIWRNFlag != 0)
				{
					errorCode = m_marshallingEngine.TTCErrorObject.m_ttiwrnNumber;
					byte[] ttiwrnMsg = m_marshallingEngine.TTCErrorObject.m_ttiwrnMsg;
					if (ttiwrnMsg != null)
					{
						char[] t = m_marshallingEngine.m_charArrayPooler.Dequeue();
						warningMsg = m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(ttiwrnMsg, 0, ttiwrnMsg.Length, t);
						m_marshallingEngine.m_charArrayPooler.Enqueue(ref t);
					}
				}
				short warningFlag = m_marshallingEngine.TTCErrorObject.m_warningFlag;
				if (warningFlag != 0)
				{
					if ((warningFlag & 0x20) == 32)
					{
						warningMsg = OracleStringResourceManager.GetErrorMesgWithErrCode(24344);
					}
					else if ((warningFlag & 4) == 4)
					{
						warningMsg = OracleStringResourceManager.GetErrorMesgWithErrCode(24347);
					}
				}
				if ((m_marshallingEngine.TTCErrorObject.m_flags & 4) == 4)
				{
					warningMsg = OracleStringResourceManager.GetErrorMesgWithErrCode(24439);
				}
				return warningMsg != null;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268697600, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetLastWarning, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.GetLastWarning);
				}
			}
		}

		public bool IsConnectionAlive()
		{
			bool flag = true;
			try
			{
				if (m_marshallingEngine != null && m_marshallingEngine.TTCErrorObject != null)
				{
					flag = IsConnectionAlive(m_marshallingEngine.TTCErrorObject.ErrorCode);
					if (flag && m_marshallingEngine.TTCErrorObject.m_bindErrors != null)
					{
						TTCArrayBindError[] bindErrors = m_marshallingEngine.TTCErrorObject.m_bindErrors;
						for (int i = 0; i < bindErrors.Length; i++)
						{
							flag = IsConnectionAlive(bindErrors[i].m_errorCode);
							if (!flag)
							{
								break;
							}
						}
					}
				}
				if (flag)
				{
					flag = IsConnectionAlive(m_lastErrorNum);
					return flag;
				}
				return flag;
			}
			catch
			{
				return flag;
			}
		}

		public static bool IsConnectionAlive(int errNum)
		{
			bool result = true;
			try
			{
				switch (errNum)
				{
				default:
					if ((errNum < 12150 || errNum > 12170) && errNum != 12237 && errNum != 12537 && errNum != 12571 && errNum != 12614 && errNum != 12547 && errNum != 12583 && errNum != 12153 && errNum != 12514 && errNum != 12570 && errNum != 12571 && errNum != 12592 && errNum != 12599 && errNum != 12614 && errNum != 31 && errNum != 376 && errNum != 1115 && errNum != 16456 && errNum != 17002 && errNum != 17008 && errNum != 17410)
					{
						return result;
					}
					goto case 22;
				case 22:
				case 28:
				case 45:
				case 378:
				case 602:
				case 603:
				case 1012:
				case 1033:
				case 1034:
				case 1041:
				case 1043:
				case 1089:
				case 1090:
				case 1092:
				case 3105:
				case 3106:
				case 3107:
				case 3109:
				case 3111:
				case 3113:
				case 3114:
				case 3116:
				case 3118:
				case 3119:
				case 3122:
				case 3123:
				case 3124:
				case 3125:
				case 3133:
				case 3135:
				case 3136:
				case 3137:
				case 3140:
				case 3141:
				case 3146:
				case 6400:
				case 6401:
				case 6402:
				case 6403:
				case 6404:
				case 6405:
				case 6406:
				case 6407:
				case 6408:
				case 6409:
				case 6410:
				case 6411:
				case 6412:
				case 6413:
				case 6414:
				case 6415:
				case 6416:
				case 6417:
				case 6418:
				case 6419:
				case 6420:
				case 12608:
				case 12609:
				case 21500:
				case 27146:
				case 28511:
					result = false;
					return result;
				}
			}
			catch
			{
				return result;
			}
		}

		internal object TemporaryLobReferenceGet(string lobId)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceGet);
			}
			object result = null;
			try
			{
				lock (m_lockForLists)
				{
					result = m_temporaryLobReferences[lobId];
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceGet);
				}
			}
		}

		internal void TemporaryLobReferenceAdd(string lobId, object lobImpl, bool bumpRefCount = true)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceAdd);
			}
			try
			{
				lock (m_lockForLists)
				{
					m_temporaryLobReferences.Add(lobId, lobImpl);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceAdd);
				}
			}
		}

		internal void TemporaryLobReferenceRemove(string lobId)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceRemove);
			}
			try
			{
				lock (m_lockForLists)
				{
					m_temporaryLobReferences.Remove(lobId);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.TemporaryLobReferenceRemove);
				}
			}
		}

		internal override bool TransportAlive()
		{
			return m_oracleCommunication.TransportAlive;
		}

		internal void InbandNotificationProcessing(int InbandErr1, int InbandErr2, int InbandEMFI, string InbandErrMsg, object InbandErrContext)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262400, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.InbandNotificationProcessing, "(err1={0}) (err2={1}) (emfi={2}) (msg={3})", InbandErr1.ToString(), InbandErr2.ToString(), InbandEMFI.ToString(), InbandErrMsg);
			}
			try
			{
				m_pm.RemoveDeadConnections(this);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)262656, OracleTraceClassName.OracleConnectionImpl, OracleTraceFuncName.InbandNotificationProcessing);
				}
			}
		}
	}
}
